Professional Documents
Culture Documents
void setup()
{
pinMode(IR_Pin, INPUT); // Set the IR sensor pin as input
pinMode(ledPin, OUTPUT); // Set the LED pin as output
}
void loop()
{
int irSensorState = digitalRead(IR_Pin); // Read the state of the IR sensor
if (irSensorState == HIGH)
{
// If the IR sensor detects an object, turn the LED on
digitalWrite(ledPin, HIGH);
}
else
{
// If the IR sensor does not detect an object, turn the LED off
digitalWrite(ledPin, LOW);
}
}