tutorial
IR Proximity Sensor Interface With Arduino
An infrared sensor is an electronic instrument that is used to sense certain characteristics of its surroundings. It does this by either emitting or detecting infrared radiation. Infrared sensors are also capable of measuring the heat being emitted by an object and detecting motion.
This is an infrared sensor which can be used for obstacle sensing. The sensor provides a digital output. The sensor outputs a logic one(+5V) at the digital output when an object is placed in front of the sensor and a logically zero(0V) when there is no object in front of the sensor. An onboard LED is used to indicate the presence of an object. This digital output can be directly connected to an Arduino to read the sensor output.
IR sensors are highly susceptible to ambient light and the IR sensor on this sensor is suitably covered to reduce the effect of ambient light on the sensor. The onboard potentiometer should be used to calibrate the sensor. To set the potentiometer, use a screwdriver and turn the potentiometer until the output LED just turns off.
Feature of IR sensors:
1. Can be used for obstacle sensing, color detection(between basic contrasting colors), fire detection, line sensing, etc and also as an encoder sensor.
2. Input Voltage: 5V DC
3. Comes with an easy to use the digital output.
4. Can be used for wireless communication and sensing IR remote signals.
5. The sensor comes with ambient light protection.
6. The sensor has a hole of 3mm diameter for easy mounting.
2. Input Voltage: 5V DC
3. Comes with an easy to use the digital output.
4. Can be used for wireless communication and sensing IR remote signals.
5. The sensor comes with ambient light protection.
6. The sensor has a hole of 3mm diameter for easy mounting.
Specification:
IR Sensor has three Lines:
1. +5V VCC
2. GND
3. D0 or OUT (Digital Output)
Connection Diagram:
Arduino interfacing with IR Proximity sensor is very simple like interfacing of Switch with the Arduino, The obstacle sensor gives logic 0 as output when there is no obstacle in front of it, and when an obstacle is placed in front of it, it will give logic high output i.e. +5V. We need to read these logic changes on the Arduino. using digitalRead Command.
Code:
int outputPin = 7; // This is our input pin
int hasObstacle = HIGH; // HIGH MEANS NO OBSTACLE
void setup()
{
pinMode(outputPin, INPUT);
Serial.begin(9600);
}
void loop()
{
hasObstacle = digitalRead(outputPin); //Reads the output of the //obstacle sensor
Serial.println(hasObstacle);
if (hasObstacle == HIGH) //HIGH means something is ahead
{
Serial.println("Stop something is ahead!!");
delay(1000);
}
else
{
Serial.println("Path is clear");
}
delay(200);
}
Output:
1. Place the object in front of the IR proximity sensor and observe the change in LED connected to Pin 13 (onboard LED)
2. When you remove the object you will see it gets turned off.
“If there is any obstacle the onboard led will glow.
If there is no obstacle the onboard led will not glow.”
No comments:
Post a Comment