Infrared Proximity Sensors can be used for different types of applications like obstacle sensing, color detection, fire detection, line sensing, etc, and also as an encoder sensor. The sensor provides a digital output of 5v DC when there is an object in front of the sensor.
Today in this tutorial we are going to show step by step how to interface this Infrared Proximity Sensor with Arduino microcontroller to make cool projects.
Hardware Components
S.NO | Component | Value | Qty |
---|---|---|---|
1. | Arduino Uno R3 | – | 1 |
2. | USB Cable A/B | – | 1 |
3. | IR Proximity Sensor | – | 1 |
4. | BreadBoard | – | 1 |
5. | Connecting Wires | – | 1 |
6. | LED | 5mm | 1 |
IR Proximity Sensor Pinout
Useful Steps
Follow all steps carefully from the video tutorial at the end of this post (Highly Recommended).
- STEP # 1 ( Make IR Sensor Connections )
- VCC – To VCC of Arduino.
GND – To GND of Arduino.
OUT – To A0 of Arduino. - STEP # 2 ( Make LED Connections )
- Cathode(-) – To GND of Arduino.
Anode(+) – To D13 of Arduino. - STEP # 3 ( Upload Code )
- Download code and upload it to Arduino Board using Arduino IDE Software
- https://www.arduino.cc/en/Main/Software
Circuit Diagram
Working Explanation
IR Infrared Sensor Module has a pair of infrared transmitting and receiving tubes. When the transmitted light waves are reflected back, the reflected IR waves will be received by the receiver tube. The onboard comparator circuitry does the processing and the green indicator LED comes to life.
The module features a 3 wire interface with Vcc, GND, and an OUTPUT pin on its tail. It works fine at 3.3 to 5V levels. Upon hindrance or reflectance, the output pin gives out a digital signal (a low-level signal) The onboard preset helps to fine-tune the range of operation, the effective distance range is 2cm to 80cm.
Arduino Code
int analogInPin = A0; // Analog input pin that the potentiometer is attached to int out =13; int sensorValue = 0; // value read from the pot void setup() { // initialize serial communications at 9600 bps: Serial.begin(9600); pinMode(out, OUTPUT); } void loop() { // read the analog in value: sensorValue = analogRead(analogInPin); Serial.print("sensor = " ); Serial.println(sensorValue); delay(200); if(sensorValue>800) { digitalWrite(out,1); } else { digitalWrite(out,0); } }
Applications
- IR sensor modules are used in radiation thermometers to measure the temperature based on the color & material of the object.