const int proximity=5; //pin5 of port P1 connected to IR sensor
int value=0;
void setup() {
Serial.begin(9600);
pinMode(proximity, INPUT); //declared as input
delay(100);
}
void loop() {
value=digitalRead(proximity); // storing sensor data in a variable.
delay(1000);
if(!value) //check for an obstacle if present.
{
Serial.println("obstacle detected.."); //display this message when obstacle detects
}
}