

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


#define IRpin 2 #define ledPin 13 void setup() { pinMode(IRpin,INPUT); pinMode(ledPin,OUTPUT); } void loop() { int sensorValue = digitalRead(IRpin); // Read the IR sensor output if (sensorValue == LOW) { digitalWrite(ledPin, HIGH); Serial.println("Obstacle detected!"); } else { digitalWrite(ledPin, LOW); Serial.println("No obstacle."); } }