The following sketch reads the digital state of the FC-51 sensor and prints the detection status to the Serial Monitor. It also toggles the Arduino's built-in LED (Pin 13) when an obstacle is detected.
Note: Turning the potentiometer too far clockwise will cause the sensor to lock into a permanent "LOW" state, indicating an obstacle even when the path is completely clear. Interfacing FC-51 with Arduino Fc 51 Ir Sensor Datasheet
Decreases sensitivity, requiring objects to be closer to the sensor to trigger an output. The following sketch reads the digital state of