Picture of Proximity-Sensing LEDs

This project of mine started because I wanted to learn how to layout my own printed circuit board (PCB). I needed a simple and easy-to-solder circuit, so I chose this one because who doesn't love interactive LEDs?

In this Instructable I will only be showing the implementation of my circuit on a breadboard. In my next Instructable (now available here), I will demonstrate my process of designing and laying out the PCB.

As I mentioned I wanted a simple project and this one is just that! Students, hobbyists, and anyone else of all skill levels will be able to easily put this together. Let's get started!

Remove these adsRemove these ads by Signing Up

Step 1: Introduction to the Circuit

Picture of Introduction to the Circuit
Untitled Sketch_schem.png

This step is the "How it Works" section. If you prefer to get right into making the circuit, skip to the next step.

If you're still with me, I'm going to start with a brief introduction of some of the components I used in this circuit. (An exact list of materials is in the next step.)

  • The component that looks like a black LED is not actually an LED at all. It is a photo-transistor. How does a photo-transistor work? When the photo-transistor receives a certain wavelength of light, it "turns on" and allows current to flow through it. When the photo-transistor is not receiving that wavelength of light, it is "off". That being said, the photo-transistor is essentially acting as a switch in our circuit. Note: The photo-transistor I used is made to respond best to light with a wavelength of 880nm.
  • The pink LED in the image above is an infrared (IR) LED which does exactly what it sounds like it would do. Rather than emitting light that our eyes can see, it emits light in the infrared range of the electromagnetic spectrum. It is in series with a 220Ω current-limiting resistor to protect it from burning out. Note: The IR LED I used is made to emit light at a wavelength of 880nm. Sound familiar? I'll get back to this in a bit.
  • The blue LED is just that, a blue LED. It is also connected to a 220Ω current-limiting resistor.
  • The only other components I used were resistors and wires.

So how does this all work? What makes it proximity-sensing? Remember in the explanation above that the photo-transistor acts like a switch. So when the photo-transistor is off, no current is flowing across it to our blue LED and the LED is off as well. Now look at the other side of our circuit. That's where the IR LED is connected, and it is connected such that it is always on and emitting 880nm infrared waves. Remember that I also mentioned the photo-transistor is set to respond best to wavelengths of 880nm? That's how the proximity-sensing works! When an object (such as your hand) goes over this little "cluster", IR light of 880nm is emitted from the IR LED. This light reflects off of your hand and back to the circuit. When the photo-transistor picks it up, it turns on allowing current to flow through from the source to our blue LED lighting it up!

Note: The light we're dealing with doesn't have to specifically be 880nm to for this to work. The important thing is just that the photo-transistor responds best to the wavelength of light that the IR LED emits.

1-40 of 54Next »
ukhan149 months ago

what about the distance of motion which it can sense ? what is the max range of sensing? and how can we increase the sensing distance?

Will_W_76 (author)  ukhan149 months ago

In the design I used for this Instructable, the LEDs would begin to turn on when my hand was 7-8 inches away. As my hand moved closer, the LEDs would get brighter. This range will vary depending on the specifications of each of the components you're using.

The best option for increasing this range would be to adjust the 47kΩ pull-down resistor. With a 47kΩ resistor, the blue LED in my circuit would see 0.817V when the photo-transistor was completely off (no object is nearby). As an object, like my hand, got closer, my hand got closer, the voltage at the anode of the LED would begin to increase eventually reaching a maximum value of 8.25V when my hand was only a few millimeters above the circuit.

So how would changing this resistor value increase the range? Well the blue LEDs I used don't begin to turn on until they see a voltage of about 2.2V. Again, with a 47kΩ resistor, the blue LED in my circuit would see 0.817V when the photo-transistor was completely off. So I have to move my hand close enough to the circuit that the voltage increases from 0.817 to 2.2V (by 1.4V) before my hand is "sensed" by the circuit. If the voltage at the anode of the LED is already at 2.0V when nothing is nearby and the photo-transistor is off, I would only need to move my hand close enough to cause a 0.2V increase before the LED turns on. Because less of a voltage increase is needed, the object will be "sensed" from farther away.

To get the voltage at the anode of the LED higher while the photo-transistor is off, increase the resistance of the 47kΩ resistor. Maybe try 68kΩ.

Hope this answers your question! Don't hesitate to ask me if you have any others.

ukhan14 Will_W_762 months ago
thanks a bunch Will!
amazing explanation!
kshowell made it!2 months ago

Thank you for making this Instructable. Very clear and well put together. was a fun build.


hi....can you tell me which photo transistor and IR led you used in this project??

also can i use a 6v battery in this project and what i have to do if i want to make the same with arduino???

Can you help me??? thanks a lot

Will_W_76 (author)  ishan.jain.96193 months ago

I ordered the photo-transistor and LED from Digikey. Their part numbers were QSD124-ND and 475-1469-ND, respectively.

6V would work just fine.

If you want to do this project with Arduino, you would have to connect the IR LED in such a way that it is always on. The photo-transistor would be connected to a pin designated for input, and the LED would be connected to a pin designated for output. You would then have to implement logic that says "if the photo-transistor pin is high, make the LED pin high." It would be much more tedious to connect multiple clusters to an Arduino board though.

kabanbenedek4 months ago

Hi. First of all, thanks for doing this all. I am having a trouble and after checked everything you mentioned in the below comments, I still could not figure it out. I have power from a power supply, 6V DC and I can see voltage everywhere. The IR led is on, both the IR led (L-53F3BT) and the phototransistor (L-53P3C) are 940nm. On the picture there are two 42k resistor in series. I tried with 4 as well. What I am experiencing is that I have the basic 0.8V on the blue led (which is increased to 1.9V using 4 piece of 42k resistors) when nothing in range, but when something is close the voltage is dropping instead of growing. It drops in big jumps to zero if I move my hand above it. I have double checked polarity and it should work. Something is reversed? Can you help me? Thanks.

Will_W_76 (author)  kabanbenedek4 months ago

Hi. And thank you for the comment! I was looking at the datasheet for the phototransistor you are using, and I think I found the problem. I'll start with a brief explanation.

Transistors have 3 terminals: a Base, Collector, and Emitter. For a photo-transistor, the Base is the portion that receives light. When light of the proper wavelength is received, current flows through the transistor between the Collector and the Emitter. For an NPN transistor (which is the type you are using), we want the Collector to be connected to our voltage source (your 6V). And we want the Emitter to be connected to the component that we are controlling power to (the LED).

The photo-transistor I used had the Collector on the longer lead of the package. If it were an LED, we would refer to that side as the Anode. (Refer to Step 4 for more information on this.) However, the photo-transistor you used had the Collector on the shorter lead of the package, or what would be an LED's Cathode.

All that being said, your photo-transistor is probably in backwards. It was oriented correctly based on my instructions, but our photo-transistors have different manufacturers so the Collectors are on opposite sides. Try flipping your photo-transistor around.

I hope this works! Let me know if you have any other questions. Also, here's the datasheet for the photo-transistor you are using if you would like to check it out yourself:

Thanks for the very fast response and for the solution! It works now!

What is strange though, that the regular 50W Halogen - what is the ceiling light - is making the led light up. It works cool in darkness...

Will_W_76 (author)  kabanbenedek4 months ago

Glad it's working now!

The reason it lights under the halogen light is because a halogen bulb produces a spectrum that goes into the infrared range, up to about 1000nm. That's why it turns on your photo-transistor that was manufactured for 940nm. Fluorescent and incandescent bulbs, which are more common, only produce a spectrum up to about 700nm, so it wouldn't turn on under those.

Alright, I deffinately want to put this on my next textile-intergrated project, but the problem is, i'm going to need a LOT of the transistors & IR's. What/where is the most affordable place you've been able to purchase them. I'm looking at buiying up to 100 of each.

ebay by far has the cheapest components. Order from a seller in China/Thailand that has a good rating/Best Seller rating. It will take longer to arrive but will be far cheaper than any US based store.

Will_W_76 (author)  alexis.carlsen6 months ago

I used Digi-Key for all of the parts in this project. They have the most variety and they give you a discount for buying in bulk. For example, the photo-transistor I used goes for 51 cents a piece, but if you buy 100 of them they go down to 28 cents a piece.

jmbenim Will_W_766 months ago

Do not use the below.... been waiting for 3 weeks for these parts, plus they charge shipping by the total cost, not weight.

I would love to have them by now,,, just a great project for someone that can only use breadboards, Love it.

I am having troubles with your project as easy as it is i don't know what i am doing wrong, I am building the same thing as your schematic and my led doesn't want to turn on, the only difference is that I am using an ac to dc converter and a L7808CV so instead of 9 volts, I am using 8 volts, I'vr tried to connect 3 47k redistors instead of the resistor of 47 k and nothing, and I mafe sure that my IR led is on, can you guide me on what am I doing wrong?

Hey! Thanks for the comment. Sorry it has taken me a while to get back to you, I've been super busy lately. Let's see if we can get this figured out though!

First, maybe it's just hard to tell in the picture, but the resistor on the top right of the picture that should be 47kΩ looks like it might actually be a 470Ω resistor. Like I said, it may just be hard for me to tell in the picture, but double check that.

Also, double check that your LED works. Connect it to a simple circuit to see if you can get it to turn on at all.

If all that works, grab a voltmeter. The first thing we're going to want to check is that there is the correct voltage at the power rails. In this case that is 8V, which is plenty. (I've operated this circuit with 6V.) Use your voltmeter to check that there is a voltage of 8V at each of the power rails. If there is not, check your power source and the connections at your L7808CV voltage regulator. (Here's a datasheet for that family of regulators if you need it.)

If the power is correct at the rails, we want to check the voltage at the anode of the LED next. (This is the junction where the photo-transistor, LED, and 47kΩ resistor come together.) When there is no object near the circuit, we want this voltage to be under about 2V, so the LED is off. As an object moves nearer to the circuit, this voltage should increase (above at least 2V) to begin to turn the LED on. In my configuration, I was reading 0.8V when nothing was near, and this increased to just above 8V when my hand got closer to the circuit. Connect a voltmeter here and observe the voltage range you get as your hand approaches the circuit. If you're not getting any change in the voltage at all, your photo-transistor could be defective (or it might not be configured to the same wavelength as your IR LED. Double check this. Both of mine were configured for 880nm.) If you are getting a range of voltages though, then everything is probably working correctly and you just need to increase the value of the 47kΩ resistor. I know you said you already tried using 3 (in series I'm assuming) 47kΩ, so maybe try 200kΩ. With each new resistor value that you use, check the range of voltages that you're getting at the anode of the LED.

Hopefully, one of these suggestions leads you to a solution. Let me know if you have any more questions!

nväyliö5 months ago
Just got my components. It's absolutely easy and fun project to do. I put a piece of cardboard between the clusters so the IR doesn't leak to the phototransistors. Many thanks!
Will_W_76 (author)  nväyliö5 months ago

Awesome! Thanks for sharing!

Hi. Can you tell me which ir led did you used (the part number)? cause there are plenty ir leds in the wavelength of 880nm.


Will_W_76 (author)  nikos.paschalidis.167 months ago

The IR LED part number is 475-1469-ND on DigiKey.

bergerab7 months ago

Wow this is awesome! The applications this can be used in are huge. I'm definitely going to add this to future projects. Thanks for sharing!

nejo00177 months ago

Thanks for sharing! I love the simplicity.

This is amazing, I'm mezmerized by the gif at the beginning! Awesome job!


Really cool project! I'm trying to build one myself but it seems i'm stuck on something..

I'm using 3mm IR led emitters and receivers both at a range of 940nm. I'm trying to turn on a 3mm green led with his own 100Ohm resistor.. But its not working properly.. When i just turn on the green led, its much brighter then when i try to switch it on using the IR leds.. I've changed the resistors to different values but its still very weakly litt...

I'm hoping that you have a solution for this 'odd' problem..


Will_W_76 (author)  jeroen.linden.18 months ago

Thanks for the question! If it's very weakly lit, it's probably because more current is flowing through the photo-transistor (IR receiver) to ground rather than to the LED. You mentioned that you changed the resistor values. What values are you using? The resistor that we want to adjust to fix this is the 47kΩ resistor. If your LED is only barely lighting, try increasing this value. Another time when I made the circuit with some different parts, I was actually using a 10MΩ resistor here! So there's a big range of acceptable values that depend on the specific qualities of your LEDs.

If you are still having trouble, check you're IR LEDs by looking at them through a camera to make sure they're lighting up. If you need more assistance don't hesitate to ask. Good luck!

carlos66ba8 months ago

Nicely done.


I'm wondering what P/N have you used as 880nm IR photo-transistor?

Will_W_76 (author)  bohdan.kovalchuk.948 months ago

Hi! The part number of the photo-transistor I used was QSD124-ND. If you click on it, I included a link to it's page on DigiKey where I bought it.

Got it, thanks!

rockyt9 months ago

One more question, any idea on why my version lights up and stays lit when power is supplied? What other resistor values might I use?

Will_W_76 (author)  rockyt9 months ago

To answer your first question: The photo-transistor and IR LED I used mostly emit and receive through the top. It is likely there is some light going through the sides of both, but it's mostly insignificant.

The likely reason that your LED is always on is because of the value of your pull-down resistor (the 47kΩ resistor in my design). Reducing this value should solve that problem. I would reduce this value in steps and see how your circuit performs with each different resistor value. (A voltmeter would be helpful and precise here, but is not essential.) If you want more specific details on how pull-down resistors work and how to select the right values, read some of my responses to other user's comments below. I go into quite a bit more detail.

scottinnh9 months ago

This is a nice project, made simple and approachable by newbies. Starting out on a breadboard is a user-friendly touch.

This is similar to (though probably not copied from) Evil Mad science "Octolively", and I place the link here for those who may want to read another writeup on how to do this:

Will_W_76 (author)  scottinnh9 months ago

I actually included a link to Evil Mad Science's video of their OctoLively in response to another user's comment on this Instructable! They have a really cool board.

Thanks for the comment!

rockyt9 months ago

Greetings Will,

I tried, for sometime last night, to create this circuit.

From Radio Shack I purchased an emitter and detector, they were in the same packaging so I assume they are made for each other. When I assembled the circuit, as soon as I supplied current the led lights up and stays lit.

at first I thought maybe the detector was too close to the emitter and it was

detecting and lighting the led. So, I disconnected the emitter and there was no change. That is, the led remained lit up. I used the same resistors as outlined in your instructable.

Question: Does the detectors used in your circuit only detect from the top of the detector? What prevents your detector from receiving ir light from the emitter while you are NOT moving your hand or ruler over it?

Thanks Will

PiotrS9 months ago

dose it work if you put sanded glass on it ?

Will_W_76 (author)  PiotrS9 months ago

I don't have any sanded glass to test this myself, but I would guess that it will work. Just make sure the LEDs are right up against the glass. This minimizes reflection from the glass to the photo-transistor. The only other setback you might have is a reduced range of sensing.

Jooks9 months ago

Will this method of proximity-sensing work under glass? I'm wonder if the glass would reflect back too much of the light and leave the LEDs powered on the whole time.

Will_W_76 (author)  Jooks9 months ago

Yes! I just tested it through glass and it worked the perfectly! I did notice a potential issue though. Make sure that the LEDs are completely against the back of the glass. This positioning seems to make sure that most of the light gets through the glass rather than being reflected back right away. If I held the LEDs a few inches back from the glass, the blue LED would faintly light up even if there were no objects on the other side of the glass.

Also, I tested this with completely clear glass. I don't know what you had in mind, but the opacity of whatever glass you are planning to use may or may not have an effect on it. But I would guess it would still work at least to some extent. Let me know how this works out for you!

alcurb9 months ago
I love your project. I love anything to do with LEDs.

I haven't tried this myself but wouldn't it be cool if you wave your hand leaving a lighted trail that dims to dark in about a second? I think that the effect could be achieved by adding a capacitor to delay when the circuit turns off rather than turning off instantaneously. Cheers.
1-40 of 54Next »