int irSensorPin = 2;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // Initialize serial communication for debugging
pinMode(irSensorPin, INPUT); // Set the IR sensor pin as an input
}
void loop() {
// put your main code here, to run repeatedly:
int irSensorValue = digitalRead(irSensorPin); // Read the IR sensor value (HIGH or LOW)
if (irSensorValue == LOW) {
Serial.println("Object Detected!"); // Print a message if an object is detected
} else {
Serial.println("No Object Detected"); // Print a message if no object is detected
}
delay(1000); // Delay for 1 second (adjust as needed)
}