When I started with arduino, and electronics, I always wanted to do things the cheap way.

Nothing has changed.

Step 1: Parts

You will need:
- Infrared LED
- Infrared photodiode
- Arduino
- Wires of some sort
- Electrical tape, duct tape, even hot glue!
- Heat shrink
- Perhaps a breadboard for testing

Step 2: Constructing the Sensor 1, Soldering

First off the sensor will be soldered together.

As you can see in the pictures, both the LED and the photodiode have a long and a short leg. The short legs should be connected to eachother like you can see in the picture. Any questions?

Step 3: Constructing the Sensor 2, Covering

The photodiode will be covered, so any ambient light won't affect the readings. This will be done with some heatshrink tubing, or duct tape. Heat shrink is recommended.

Cut off a section of heat shrink a bit longer the black blob on your photodiode. Put it on and heat it! Easy, right?

Step 4: Finishing, Arduino.

You will now have an LED and a photodiode soldered together. You can either glue these together, tape them together (wich I think is neater) or heatshrink together(neatest).
What results is something like picture

Connect the long pin of the LED with +5v, the short pins to GND and the long photodiode lead to a pin on your Arduino. Preferably an analog pin. Set it as INPUT and write it HIGH to activate the internal pullup resistor. The lower the value analogRead() gives, the closer something is.

an example code, you can upload this to your arduino board. The LED will light as soon as the obstacle comes close. Increasy the integer sensitivity to increase the distance to activate. Watch out though! Too much and you won't be able to sense because of ambient light!

int LED = 13;
int sensor = A0;
int distance;
int sensitivity = 700

void setup()
pinMode(LED, OUTPUT);
pinMode(sensor, INPUT);
digitalWrite(sensor, HIGH);

void loop()
distance = analogRead(sensor);
if (distance < sensitivity)
digitalWrite(LED, HIGH);}


<p>I tried to do it</p><p>But instead got my IR LED Burnt..!!</p>
<p>Help me Please!! i did almost exactly like this but on my own, just had added resisters( but i dont remember the values :( ),, at that time it worked but now this is not working,,,,i searched internet and found this which is almost exactly like mine version,, but mine readings are mostly zero's and few values up for 5 to 10 steps and then again zero, Help PLZ !!!! else tell me some way to do ir sensor simply</p>
<p>hey I am a new user to instructables,</p><p>I am correctly working on a project to find the speed of an moving metal ball(about 1mm of radios) but, I have a question, your idea is really good and cheap.</p><p>Will this circuit be able to recognize the ball(1mm radios) at high speeds ??</p>
<p>Nice! I like it. Compact, simple, and it works.</p><p>P.S. I like your profile pic. Very funny.</p>
<p>awesome project.........really cheap.............i nly changed the sensitivity to 500......thanks </p>
hii dunnos ! cheap and cool instructable but there is a problem for me .i am going to make a efficient road lightning system as my school project . using your ideaa i want streetlights to turn on when there is a obstacle say car in front. but i want to connect different 3 pairs of sensors on different points on miniature road say at distance of 5 cm and when obstacle comes in front of any sensor the led connected should turn on. Could u help me <br>THANKS !! <br>
interesting.<br>Since the program seems to measure amount of light reflected, I presume the outcome also depends on reflection of the approaching object. Also as it is IR, a warm object wld probably give a different reading than a cold object. (I understand the code is only to test the functionality of yr sensor design)<br><br>Nevertheless an interesting set up <br><br>One wld be tempted to use the same sensor you constructed and send a pulse to the LED, measuring the time it took for that pulse to come back
This is just a very crude sensor, one would just use it for obstacle detection in a cheap robot. <br><br>Interesting idea with the pulse but I don't know if that would be that easy... light travels at 300 000 m/s so the reading would be too fast for your average microcontroller.<br><br>If you try, make a picture :)
:-) Did not want to critcize, I understand it is just a crude (but useful thing).<br>It is actually even worse. Light goes 300.000 Km/sec. I think I was being a bit too academic about it
Just to say, IR is the slowest light. (I think)
cute :) <br> <br>all light has the same speed, just the energy is different because it's a wave. <br> <br>Or I am completely missing something and making a fool of myself :p
OK, on an academic level: modulating the outgoing light with a lower frequency and measuring the frequency shift :-)<br>Hmm, better to keep it simple :-)
doppler effect?
Don't worry, is working again <br> <br> <br>Thanks <br> <br>great instructable
It doesn't work for me <br> <br>i connect the pins correctely and the serial port give me always 0
What happens when you disconnect the sensor? Perhaps try another analog port?
Great intro!<br>

About This Instructable




More by dunnos:Cheap obstacle sensor - with Arduino! Digital Dice: an Arduino project. How to clean a keyboard 
Add instructable to: