When an object enters the detection zone, it reflects the infrared light back toward the sensor.
The following sketch reads the state of the FC-51 sensor. It turns on the built-in Arduino LED (Pin 13) and prints a message to the Serial Monitor whenever an obstacle is detected.
2cm to 30cm (adjustable via onboard potentiometer). Detection Angle: ~35°.
Lights up immediately when the module receives power.
Mounted on the front or sides of wheeled robots to prevent collisions.
If you are planning to integrate this sensor into a specific design, let me know:
print('Checking for obstacles...') while True: if sensor.value() == 0: print('Obstacle detected!') switching() # Debounce: Wait until the sensor is clear again while True: time.sleep(0.5) if sensor.value() == 1: break time.sleep(0.1)
Turn the potentiometer counter-clockwise until the indicator LED turns off, then test with an object.
The FC-51 is very straightforward to use with any Arduino board.
Triggers automatic water faucets, hand sanitizers, or paper towel dispensers when hands approach. Limitations and Troubleshooting
Illuminates when an object enters the detection range and triggers the output. Working Principle The FC-51 operates on the principle of infrared reflection.
The effective range of the FC-51 depends heavily on the color and texture of the obstacle. Black surfaces absorb infrared light, significantly reducing the detection range (sometimes down to zero). Conversely, white or highly reflective surfaces maximize the detection range. Interfacing FC-51 IR Sensor with Arduino Uno