Professional Documents
Culture Documents
h>
Servo myservo;
int analogInPin = A0; // Analog input pin that the potentiometer is attached to
int buzz = 2;
int pos = 0;
void setup() {
myservo.attach(9);
Serial.begin(9600);
pinMode(out, OUTPUT);
pinMode(buzz, OUTPUT);
void loop() {
sensorValue = analogRead(analogInPin);
Serial.print("sensor = " );
Serial.println(sensorValue);
delay(200);
if(sensorValue<800)
digitalWrite(buzz,HIGH);
myservo.write(0);
if (sensorValue<500){
digitalWrite(buzz,HIGH);
myservo.write(180);
if (sensorValue>800){
digitalWrite(buzz,LOW);
myservo.write(0);