FC-51 IR Sensor Module
FC-51 IR sensor module is a proximity sensor module. We can identify obstacle in front of sensor. So it has built in IR transmitter and IR receiver. It also has built in potentiometer to adjust distance rage. IR sensor module operate in 2cm-30cm range. FC-51 is compatible with Arduino.
Technical Specification
1. Operation Voltage - 3.3V - 5V2. Detection Angle -35 degrees
3 Active Output level - Outputs Low logic level when obstacle is detected
4.Detection range: 2cm – 30cm (Adjustable using potentiometer)
PIN Out & In
1. VCC - 3.3V-5V DC power input2. GND -0V Power pin
3. OUT - Digital Output Pin
Programming
There are may way to do it. So here i try to use IR sensor with Arduino Uno board. When obstacle is detected by sensor, it will generate LOW output, otherwise output is HIGH.
Example 1
Example 1
int irSenRead =7;
int isObstacle = HIGH;
void setup() {
pinMode(irSenRead ,INPUT);
Serial.begin(9600);
}
void loop() {
isObstacle = digitalRead(irSenRead); // // Read IR sensor output
Serial.println(digitalRead(irSenRead)); // // print the output
// // isObstacle ==low there is obstacle infront of sensor
// // using serial monitor we can see this output
if (isObstacle == LOW) {
Serial.println("OBSTACLE");
}
else
{
Serial.println("NO");
}
delay(500);
}
Example 2
In below code sample .LED bulb will be on when obstacle detected
int irSenRead =7;
int LED=6;
int isObstacle = HIGH;
int delayRead =100;
void setup() {
pinMode(irSenRead ,INPUT);
pinMode(LED ,OUTPUT);
Serial.begin(9600);
}
void loop() {
isObstacle = digitalRead(irSenRead);
Serial.println(digitalRead(irSenRead));
// isObstacle ==low there is obstacle infront of sensor
if (isObstacle == LOW) {
digitalWrite(LED ,HIGH);
}
else
{
digitalWrite(LED ,LOW);
}
delay(delayRead);
}