INTERFACING
OF IR SENSOR
WITH ARDUINO
IR stands for Infra Red.
This sensor ia an electronic device and senses
the presence of obstacles, motion
of the object. It sends the infrared rays through the emitter and it receives
the reflected rays. In case if there is no obstacle the rays are not reflected
and the sensor gives the certain output.
One feature of
this sensor is that, these infrared rays are absorbed by black colored objects
and the sensor senses the black color.
The above figure is the most advance
design of the IR sensor
· It contains three pins – VCC, Ground, Signal .
· In IR sensor Signal pin is connected to digital pin in the development boards like ARDUINO.
· IR sensor gives the output of digital signal only.
· Operating Voltage of this sensor is +5V.
· This sensor can detect the black light.
· The frequency of the IR waves emitted out are about 700nm -1400nm.
· This Infrared Red sensor works on the principles – Plank’s Radiation Law and Wien’s Displacement Law.
CONNECTING THE IR SENSOR WITH ARDUINO
The Sensor connection to the ARDUINO is discussed in the following steps :
There will be three pins present on the IR sensor.
· First pin VCC must be connected to the 5V supply on the ARDUINO board.
· Next the GROUND pin of the IR sensor must be connected to the ground on the ARDUINO board.
· Finally the SIGNAL pin of the IR sensor must be connected to the any of the digital signal pin on the ARDUINO board.
· The connections from IR sensor to the ARDUINO board must be connected with the help of male-female wire.
· Now the power supply is given to the ARDUINO for the functioning of ARDUINO and IR sensor connected to it.
With this entire interfacing of IR sensor with ARDUINO is successfully completed and finally step is to dump the program to the ARDUINO board for the functioning of the IR sensor and to get the output results from the sensor.
The functioning of this IR sensor starts when the power supply is given to it. But it is programmed accordingly to expect the results from it as per our necessity.
ARDUINO PROGRAM OF IR SENSOR
void setup() {
pinMode(2,INPUT);
Serial.begin(9600);
pinMode(13,OUTPUT);
}
void loop() {
Serial.print("IRSensorip ");
Serial.println(digitalRead(2));
if(digitalRead(2)==0)
{
digitalWrite(13,HIGH);
}
else{
digitalWrite(13,LOW);
}
}
FUNCTIONING IR SENSOR
After the successful writing of code in the ARDUINO IDE and successful dumping of program into the ARDUINO Development Board, the output values of the IR Sensor will be visible on the Serial Monitor. But here the display on the serial monitor is different from the Ultra Sonic sensor serial monitor display. For the IR sensor since it is a digital output, only the values of 1 and 0 are displayed on the serial monitor.
EXPLANATION OF THE PROGRAM
Here, the SIGNAL pin of IR sensor is connected to the digital pin number 2 of the ARDUINO Board. Now, when the program is dumped, there establishes a serial communication between ARDUINO and IR Sensor.
· In the initial step SIGNAL Pin 2 is selected as INPUT Pin.
· Now serial communication, is declared with baud rate 9600.
· Next, Pin 13 is declared as Output pin.
· Now, In the loop IR SENSOR is declared.
· And the read of value from Pin 2 is declared.
· If the read of value from Pin 2 is 0, Output Pin 13 is kept HIGH, or else LOW.
· IR Sensor mainly contain Infrared Receiver , Infrared Source , Medium for propagation of IR waves.
Here, in this interfacing if the input read value from IR sensor is 0, that practically mean some object is present infront of the sensor. In that case pin 13 is kept HIGH . If it reads a value of 1 , that practically mean no object is present or the black absorbing surface is present. In that case Pin 13 is kept LOW.
CONCLUSION
The above given information is all about the interfacing of IR sensor with ARDUINO and its working and the output results of the IR sensor.
This information can be used to understand brief about the IR sensor working with ARDUINO and promote the development of Autonomous Robotic Projects by using the IR sensor and other components as well.