#include <Servo.h> // servo library
Servo s1;
int val = 0 ;
int va2 = 0 ;
void setup()
{
Serial.begin(9600); // sensor buart rate
pinMode(2,INPUT); // IR sensor 1
pinMode(3,INPUT); // IR sensor 2
s1.attach(9); // Servo Connect 9 pin
s1.write(0);
}
void loop()
{
val = digitalRead(2); // IR sensor 1 output pin connected
va2 = digitalRead(3); // IR sensor 2 output pin connected
Serial.println(val); // see the value in serial mpnitor in Arduino IDE
Serial.println(va2); // see the value in serial mpnitor in Arduino IDE
delay(10); // Time Delay
if(val == 1 )
{
s1.write(0); // SERVO 0 DEGREE
}
if(va2 == 1 )
{
s1.write(90); // SERVO 90 DEGREE
}
}