Nothing has changed.
Step 1: Parts
- Infrared LED
- Infrared photodiode
- 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
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
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.
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 sensitivity = 700
distance = analogRead(sensor);
if (distance < sensitivity)