#include <Servo.h>
Servo myservo1; // create servo object to control a servo
const byte goodPin = 7;
const byte badPin = 2;
const int servoPin = 3;
const byte outPin = 13;
void setup() {
pinMode(13, OUTPUT);
pinMode(7, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
myservo1.attach(servoPin);
}
void loop() {
if(digitalRead(goodPin) == LOW){
digitalWrite(outPin, HIGH);
delay(100);
digitalWrite(outPin, LOW);
myservo1.write(40); //setting servo1 accept tilt (set to -40)
delay(700); //wait
myservo1.write(90); //setting servo1
}
if(digitalRead(badPin) == LOW){
digitalWrite(outPin, HIGH);
delay(100);
digitalWrite(outPin, LOW);
myservo1.write(140); //setting servo1 accept tilt (set to 140)
delay(700); //wait
myservo1.write(90); //setting servo1
}
}