Introduction
- The IR Proximity sensor is to perceiver the occurrence of any object without beginning in contact with with-it.
- It senses the accurate distance of a particular object.
- It will emit electromagnetic radiation.
Figure1: IR sensor
IR LED Emitter:
- It will also emit light.
- When the object occurs it will produce light
Figure 2: IR Emitter
Parts Of List:
- Arduino UNO
- IR Led Receiver
- IR Emitter
- Bread Board
- Hookup Wires
- Buzzer
Connection
Step 1: Fix the IR Receiver on the breadboard.
Step 2: Fix the IR Emitter 4 on the breadboard.
Connection Of Bread Board To Arduino:
Step 1: Take the IR Receiver Gnd pin to the Analog pin A0, then Vcc to the Digital pin 02.
Step 2: Take the IR Emitter to connect the Gnd pins commonly then Vcc pins commonly.
Step 3: Connect to the Arduino UNO board.
Step 4: Fix the buzzer in the Arduino board.
Program:
- int IRpin = A0; // IR photodiode on analog pin A0
- int IRemitter = 2; // IR emitter LED on digital pin 2
- int ambientIR; // variable to store the IR coming from the ambient
- int obstacleIR; // variable to store the IR coming from the object
- int value[10]; // variable to store the IR values
- int distance; // variable that will tell if there is an obstacle or not
- void setup()
- {
- Serial.begin(9600); // initializing Serial monitor
- pinMode(IRemitter, OUTPUT); // IR emitter LED on digital pin 2
- digitalWrite(IRemitter, LOW); // setup IR LED as off
- pinMode(11, OUTPUT); // buzzer in digital pin 11
- }
- void loop()
- {
- distance = readIR(5); // calling the function that will read the distance and passing the "accuracy" to it
- Serial.println(distance); // writing the read value on Serial monitor
- // buzzer(); // uncomment to activate the buzzer function
- }
- int readIR(int times)
- {
- for (int x = 0; x < times; x++)
- {
- digitalWrite(IRemitter, LOW); //turning the IR LEDs off to read the IR coming from the ambient
- delay(1); // minimum delay necessary to read values
- ambientIR = analogRead(IRpin); // storing IR coming from the ambient
- digitalWrite(IRemitter, HIGH); //turning the IR LEDs on to read the IR coming from the obstacle
- delay(1); // minimum delay necessary to read values
- obstacleIR = analogRead(IRpin); // storing IR coming from the obstacle
- value[x] = ambientIR - obstacleIR; // calculating changes in IR values and storing it for future average
- }
- for (int x = 0; x < times; x++) { // calculating the average based on the "accuracy"
- distance += value[x];
- }
- return (distance / times); // return the final value
- }
- void buzzer()
- {
- if (distance > 1)
- {
- if (distance > 100)
- {
- digitalWrite(11, HIGH);
- } else
- {
- digitalWrite(11, HIGH);
- delay(150 - distance); // adjust this value for your convenience
- digitalWrite(11, LOW);
- delay(150 - distance); // adjust this value for your convenience
- }
- } else
- {
- digitalWrite(11, LOW);
- }
- }
- In this article it can be used to detect the object at a particular distance.
- It can display the distance of an object in the Serial Monitor accurately.
- If they have the signal of the object it will produce the sound when it reaches the signal.
Figure 3: Output
Read more articles on Arduino:


Sr KarthigaPosted Apr 19, 2016, 3:14 AM EDT
"thank you gowtham rajamanickam sir"
Gowtham RajamanickamTOP 100Posted Apr 19, 2016, 2:42 AM EDT
good article
Sr KarthigaPosted Feb 9, 2016, 9:38 PM EST
Thank you Anu Vivin sir
Anu VPosted Feb 9, 2016, 8:43 PM EST
Nice
Sr KarthigaPosted Feb 9, 2016, 3:48 AM EST
Thank you raja sir
Raja TPosted Feb 9, 2016, 3:46 AM EST
Nice, Thanks for sharing
Sibeesh VenuTOP 100Posted Feb 7, 2016, 7:12 PM EST
Nice Share
Sr KarthigaPosted Feb 6, 2016, 11:32 PM EST
Arduino is a microcontroller based physical computing platform. Rasberry pie is microprocessor based single-board computer (SBC).
Sr KarthigaPosted Feb 6, 2016, 11:27 PM EST
Thank you Shubham Kumar sir
Saillesh PawarPosted Feb 6, 2016, 8:24 PM EST
what is the difference between Arduino and Rasberry pie?
Shubham KumarPosted Feb 6, 2016, 1:57 AM EST
nice
Sr KarthigaPosted Feb 5, 2016, 3:45 PM EST
Thank you Jaco Zwarts sir
Sr KarthigaPosted Feb 5, 2016, 3:45 PM EST
Thank you Pramod Thakur sir
Sr KarthigaPosted Feb 5, 2016, 3:44 PM EST
Thank you Mohammed sir
Sr KarthigaPosted Feb 5, 2016, 3:44 PM EST
Thank you santhakumar sir
Sr KarthigaPosted Feb 5, 2016, 3:42 PM EST
Thank you kumaresh sir
Santhakumar MunuswamyPosted Feb 5, 2016, 10:32 AM EST
Thanks for nice article. Keep it up
Kumaresh RajalingamPosted Feb 5, 2016, 9:19 AM EST
Nice share
Mohammed IbrahimPosted Feb 5, 2016, 8:12 AM EST
nice
Jaco ZwartsPosted Feb 5, 2016, 7:17 AM EST
Nice, Thank you for sharing
Pramod ThakurPosted Feb 5, 2016, 6:30 AM EST
thanks for sharing..