The FC-51 Obstacle Sensor is an infrared proximity sensor designed for robotics and automation applications. It detects obstacles within a range of 2-40cm and provides a digital output that indicates the presence or absence of an object in its detection range. This sensor is widely utilized for obstacle avoidance in robots, line following, and object proximity detection.
Pin Number | Pin Name | Description |
---|---|---|
1 | VCC | Power supply input (5V DC) |
2 | GND | Ground |
3 | OUT | Digital output signal (High/Low) |
// Define the connection pin
const int obstacleSensorPin = 2; // FC-51 OUT pin connected to digital pin 2
void setup() {
pinMode(obstacleSensorPin, INPUT); // Set the sensor pin as an input
Serial.begin(9600); // Start serial communication at 9600 baud rate
}
void loop() {
int obstacleDetected = digitalRead(obstacleSensorPin); // Read the sensor value
if (obstacleDetected == HIGH) {
// Obstacle detected
Serial.println("Obstacle detected!");
} else {
// No obstacle detected
Serial.println("Clear path");
}
delay(200); // Wait for 200 milliseconds before reading again
}
Q: Can the FC-51 sensor detect all types of materials? A: The sensor is most effective with objects that reflect infrared light well. Transparent or highly reflective materials may not be detected reliably.
Q: Is the FC-51 sensor waterproof? A: No, the FC-51 sensor is not waterproof. Protect it from moisture and water to prevent damage.
Q: How can I adjust the detection range of the sensor? A: The sensor has a potentiometer that can be adjusted to fine-tune the detection threshold and range.
Q: Can the sensor work with 3.3V systems? A: The sensor is designed for 5V systems. Using it with 3.3V may result in reduced performance or no functionality. Use a level shifter if necessary.