// Pin Definitions
const int irSensorPin = 2; // IR sensor output connected to digital pin 2
const int ledPin = 13; // LED connected to digital pin 13
void setup() {
pinMode(irSensorPin, INPUT); // Set IR sensor pin as input
pinMode(ledPin, OUTPUT); // Set LED pin as output
}
void loop() {
int irValue = digitalRead(irSensorPin); // Read value from IR sensor
if (irValue == LOW) {
// Obstacle detected (typically LOW when something is in front of sensor)
digitalWrite(ledPin, HIGH); // Turn on LED
} else {
// No obstacle
digitalWrite(ledPin, LOW); // Turn off LED
}
}