Power input. Connect this pin to a 3.3V or 5V source from your microcontroller.
// Define Pins const int SENSOR_PIN = 2; const int LED_PIN = 13; // Built-in Arduino LED void setup() pinMode(SENSOR_PIN, INPUT); pinMode(LED_PIN, OUTPUT); Serial.begin(9600); Serial.println("FC-51 IR Sensor Initialization Complete."); void loop() // Read the sensor output (LOW = Obstacle, HIGH = Clear) int sensorState = digitalRead(SENSOR_PIN); if (sensorState == LOW) digitalWrite(LED_PIN, HIGH); // Turn on built-in LED Serial.println("Warning: Obstacle Detected!"); else digitalWrite(LED_PIN, LOW); // Turn off built-in LED Serial.println("Path Clear."); delay(100); // Small delay to prevent serial flooding Use code with caution. 7. Troubleshooting and Calibration
The FC-51 is a digital infrared proximity sensor. It detects obstacles by emitting an infrared signal and sensing the reflected light. It features low power consumption, a small form factor, and simple digital output interface. Key Applications Obstacle avoidance for smart cars and AGVs. Automation: Object counting on conveyor belts. Security: Proximity alarms and boundary detection. Smart Home: Touchless switches and faucet controllers. 2. Technical Specifications
What you are using (Arduino, ESP32, Raspberry Pi)? What is your target obstacle material ?
The module uses an LM393 voltage comparator IC . The comparator compares the analog voltage from the photodiode against a reference voltage set by the onboard potentiometer.
void setup() pinMode(sensorPin, INPUT); pinMode(ledPin, OUTPUT); Serial.begin(9600);