void loop() int sensorValue = digitalRead(sensorPin); if (sensorValue == LOW) // Obstacle detected digitalWrite(ledPin, HIGH); Serial.println("Obstacle!"); else digitalWrite(ledPin, LOW);
Direct sunlight or strong fluorescent lighting can saturate the IR receiver, causing false triggers. Avoid using this sensor in bright outdoor environments. Fc 51 Ir Sensor Datasheet
Used to adjust the detection range sensitivity. Turning it clockwise increases the detection distance. void loop() int sensorValue = digitalRead(sensorPin)