int p1=13;
int p2=7;
int p3=8;
void setup() {
// put your setup code here, to run once:
pinMode(p1,OUTPUT);
pinMode(p2,OUTPUT);
pinMode(p3,OUTPUT);
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(p2)==0)
{
digitalWrite(p1,LOW); digitalWrite(p3,HIGH);
Serial.println("Obstacle Detected");
delay(500);
}
else
{
digitalWrite(p1,HIGH); digitalWrite(p3,LOW);
Serial.println("No");
}
}