Professional Documents
Culture Documents
Teachers (/teachers/)
ricardouvina
(/member/ricardouvina/)
Follow 85
Simple IR Proximity Sensor With Arduino by
(/member/ricardouvina/)
ricardouvina (/member/ricardouvina/) in arduino (/explore/category/technology/keyword/arduino/)
More by ricardouvina:
Download h (/id/Simple-IR-proximity-sensor-with-Arduino/) 5 Steps .
(/id/Simple-
IR-proximity- (/id/Mood-
sensor-with- Lamp-with-
Arduino/) Arduino/)
(/file/FBCTV8JH7UR801K/)
; Group
Related
Step 1: Materials
(/file/FYRYAZEH7URBDTM/)
Be careful to don't mix up the LED receiver with the LED emitter, they all look
the same.
(/file/FOQ2QCYH7UQYPQ0/) (/file/FWL36YCH7URBDU7/)
(/file/FAMGR91H7UR7X9U/) (/file/F200SEYH7W4SMS2/)
Before mount it, we should prepare the IR LED receiver to don't receive light
from the sides, so than the sensor is more directional.
I use electrical tape to make it, but you can use a straw or anything that blocks
the light from the sides.
Cut a small piece of electrical tape and wrap it around the IR LED receiver,
forming a tube. Trim the edge with a pair of scissors until it's about 1cm long.
Have a look at images to see how I made it with electrical tape.
Write the code above on the Arduino program and upload it to the Arduino.
I also added an buzzer to this project if you wanna "hear" the distance.
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
}
Of course you can edit it to fit in your own project. You can for example make a
robot change direction or velocity based on the distance read from the IR
sensor.
IR_proximity_sensor.zip
Download (https://cdn.instructables.com/ORIG/FB2/3VAZ/H7UQYPQ9/FB23VAZH7UQYPQ9.zip)
(https://cdn.instructables.com/ORIG/FB2/3VAZ/H7UQYPQ9/FB23VAZH7UQYPQ9.zip)
(/file/FNPJB5FH7W4SQOS/) (/file/F4R55XIH7UQN2N9/)
(/file/F5AP73OH7W4SQVM/)
(/file/F17S7HKH7UR829N/)
Connect the resistor from the 5V pin to the anode pin of the IR LED receiver. All
the anodes pins of the IR LEDs emitters to the digital pin 2. A wire goes from the
analog pin 0 to the anode pin of IR LED receiver. Don't forget to connect all the
cathode pins of the LEDs to the ground pin.
The buzzer is optional, but if you are using it connect to the digital pin 11 and the
ground.
Infrared light isn't visible to naked eye, but you can see it thru a digital camera, it
helps to see if the LED is working or not.
Take a look at the pics.
Comments
We have a be nice comment policy.
Please be positive and constructive. w I Made it! Add Images Post Comment
If it detects black color, then how do I differentiate between white and black
color?
Also, what are the changes to be done in the code if I am using only one
transmitter?
Flag
Flag
Flag
can i have controller to send a signal from sensor wireless to another controller
to make a buzzer go off?
Flag
Flag
Flag
I have problem that my sensor is just reacting on ambient light how can i solve
this?
Flag
Flag
Alexan24 (/member/Alexan24/) 2015-11-27 Reply
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
}
Flag
Sandesh p (/member/Sandesh+p/) . Alexan24 (/member/Alexan24/) Reply
2017-02-15
Which arduino board will interface both IR sensors and image
input...... And give one output at a time..... My project is smart traffic light
control using IR sensors and image processing technique
Flag
2017-02-16
I think arduino mega or due will do the job! :)
Flag
sir. can u help me with my project. im working on project that using this
sensor. my project smart street light that can detect car movements then
the light will be on. can u help me please.
Flag
I did not understand your project much but if you replace the buzzer with
an led it will work as well! Good luck and let me know if you need anything
else!
Flag
Hello, can any one tell which arduino board will interface both IR sensors and
image input..... And give one output
Flag
Flag
Flag
Flag
when i try to use your code .. I notice the pinMode(1,OUTPUT); was active and i
don't know how to turn it off.
I made a project that's related to this code.. i hope you can help me.
Flag
Flag
hi i want to track any valuble devices like keys or etc . i want to add that sensor
that device like key or etc . so that i can check how much far from me . In this
scenario will it be helpful for me . i have seen that it detects height of a object
from the top . but i need sensor which can tell how much distance far from me.
can u tell me which device will be help ful for my project.
Flag
Flag
Flag
Hey! i'm doing this for my graduation project (including other work) .
i want a signal only if a specific distance is mesured (distance detector)
for example if a small car is standing below it will be 2 meters far from it .. if a
big car is standing below and the detector gets less then 1.2 meters it will give a
signal so the car can't get in
Flag
Hi I would like to ask if you used any pwm functions for the LEDs as usually that
is required when working with LEDs
Flag
Visitors to this instructable should understand that the IR LED setup in this
schematic is wrong on many levels. The schematic should be corrected and
updated.
There is no type of diode that can be safely and reliably connected in parallel
this way. LEDs are not resistive light bulbs. The forward voltage Vf from device
to device is not guaranteed to be the same for a given current. You are
effectively limiting the current to the diodes (and not evenly) by maxing out the
driver in the microcontroller.
In the simplest and least desirable solution you need one limiting resistor per
diode, where the resistor size is (5 -Vf)/If where If is the desired forward current
of the diode. So a typical steady 20mA and Vf of 1.3V is a resistor value of 185
ohms.
In practice you should reduce resistive losses by stacking 2 or three diodes
such that (5 - 3*Vf)/If = 55 ohms and now you get three times the light for the
same current output.
Further, considering the limitations of your power supply, the current can be
pulsed much higher, and the values read back during the on cycle, so long as
the average power dissipation stays below rated. In this case you will have to
offload the switching with an external transistor.
Flag
Hi Schuitz.
Thanks for this. I was also wondering the same. I assumed 1 limiting
resistor per emitting diode. But this could be done in parallel from the
breadboard power bus (using the Arduino as a power source). Is that
correct?
Do you also need a limiting resistor for the IR sensor (phototransistor)?
Ta
Nick
Flag
Would it make sense to switch off the LEDs in your code after checking the
distance. The current code only switches them off momentarily. Considering
that you're not using any current limiting resistors - the LEDs could get
damaged.
Flag
2016-02-22
Hi Dushyantahuja,
Did you eventually use current limiting resistors for your emitting diodes?
Ta
Nick
Flag
Flag
Flag
Also, im not using a buzzer. Im trying to extract out the distance for my
project use.
Flag
i wanted to make this for my bungalow gate but then i would have to put the
receivers on the other side right or the transmitter on the other side.
also what if i had to make this thing for my bedroom door without the bread
board.any link or anything like .
Thanks Alot
Flag
I made it!!
Flag
Update:The buzzer work but is always on...it isnt giving beeps as in the
video...??
Flag
Flag
Very low range At least for me and the photo diode is reverse biased
Flag
I think there is some error in schematic ...... I think that the reverse bias should
be added to photodiode ( IR LED Receiver) and not forward bias. I connected
up with forward bias and could not get any reading. I have even triple checked
my arduino's analog input pins. Mostly at many other IR sensor tutorials and
schematic it is reversed biased. I think Arduino is not sensitive to voltage
changes in forward bias. Please double check your schematic and your project.
Flag
2015-06-26
i her you but i dont understand where you see a issue? can you
post a quick pencil sketch pic of the proposal diagram of the renewed
schematic? thanks
Flag
Thanks for the very good example and the error logs in this posts. Keep
up the good work. I will try to move brushless motors through ESCs by
using IR proximity sensors (probably 2). I will post the example when I'm
done.
Cheers
Flag
SIM-Tech (/member/SIM-Tech/) . RukLo (/member/RukLo/) 2015-06-26 Reply
Flag
2015-04-16
Yeah, actually the vast majority of the IR sensors are supposed
to be reverse biased, and forward biasing them would create almost the
same effect of a normal IR emitter, and sometimes it may even burn the
diode.
Flag
2015-01-03
I have been faced to the same problem. My ir receiver didn't
worked in forward (I have tried with different bipolar IR receiver) but it
nicely works on reverse bias. Like you said the arduino wasn't sensible in
forward. Your comment help me much. Thank you @mgupta15
Flag
why 4 ir's emitters ? why not just 1 if is only going to be in a upwards direction?
or any direction really this works by reflecting of waves coming back from a
object in proximity and waves expands like water ripples so why 4?
Flag
Hello, nice work for putting this together, I'm wondering if there's a possibility to
replace the buzzer for a servo, I'm trying to make an IR proximity sensor that
moves the servo depending on the distance but I can't figure it out yet, any help
will be very much appreciated!
Flag
The output of the IR sensor is Vcd at certain level which in this case
Ricardo is sending it to OutPin11 "pinMode(11,OUTPUT); // buzzer in
digital pin 11"
When the voltage is too low you won't be able to move your servo but with
this same output you could move it to a certain extent. Im gonna try this
approach for a prototype but I will connect the output of the micro
controller to an ESC and a brushless motor. Before I do that I will try it on
a servo because I will be using a similar code in the ESC.
SOLUTION:
Have you tried just plugging the servo control signal to pin 11 and making
the changes in the code using the example on arduino's webpage and
replacing the pot for the IR output? See images attached and weblinks...
This webpage shows what you are attempting exactly to do but with
IR integrated sensors. SHARP brand (see image
3)http://electronics.stackexchange.com/questions/594...
(http://electronics.stackexchange.com/questions/59467/sharp-ir-distance-
sensor-outputting-consistently-high-voltage)
Arduino's forum for servo control:
http://playground.arduino.cc/Learning/SingleServoE...
(http://playground.arduino.cc/Learning/SingleServoExample)
Important: You will have to make some changes to the code posted
in Ricardo's example and combining it with what the servo needs.
Let me know how it goes? I will have my code in about a week. I am using
a SHARP IR sensor instead due to the application but it is the same
principle.
(https://cdn.instructables.com/F3A/HSNN/IAWC31ID/F3AHSNNIAWC31ID.LARGE.jpg)
(https://cdn.instructables.com/F8R/YU9Q/IAWC31K4/F8RYU9QIAWC31K4.LARGE.jpg)
(https://cdn.instructables.com/F92/BSAB/IAWC31TI/F92BSABIAWC31TI.LARGE.jpg)
Flag
Flag
Flag
2014-01-03
The value 150 he imposed as a "threshold", where the "beeps"
from the buzzer will repeat at decreasing rates, since the
distance(variable) will get higher(because the object is getting close)
providing the distance variable value to be inversely proportional to the
real, physical distance measure.
Flag
2015-03-15
on line 55 and 57, I am wondering what happened more than
151 negative number of distance? if 150 - 151(151 is convert distance
number) will be negative 1. because it said delay(150 - distance); , so will
it work if delay(-1) function?
```
void buzzer(){
if (distance>1){
digitalWrite(11,HIGH);
}
else{ // beeps faster when an obstacle approaches
digitalWrite(11,HIGH);
digitalWrite(11,LOW);
}
else{ // off if there is no obstacle
digitalWrite(11,LOW);
```
Flag
Flag
I More Comments
Newsletter About Us
Let your inbox help you discover our best Who We Are (/about/)
projects, classes, and contests. Instructables Advertise (/advertise/)
will help you learn how to make anything! Contact (/about/contact.jsp)
Jobs (/community/Positions-available-at-Instructables/)
enter email I'm in!
Help (/id/how-to-write-a-great-instructable/)
Find Us Resources
Facebook (http://www.facebook.com/instructables) For Teachers (/teachers/)
Youtube (http://www.youtube.com/user/instructablestv) Residency Program (/pier9residency)
Twitter (http://www.twitter.com/instructables) Gift Premium Account (/account/give?sourcea=footer)
Forums (/community/?categoryGroup=all&category=all)
Pinterest (http://www.pinterest.com/instructables)
Answers (/tag/type-question/?sort=RECENT)
Google+ (https://plus.google.com/+instructables)
Sitemap (/sitemap/)