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!

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 64Next »
AmilaR116 hours ago

Hi, i love this project, this is something i wanted to do badly but didn't know how to. I'm new to electronics. i made the circuit as you explained. but its not working. i tried to troubleshoot as you have explained. my ir led is not working at all. i tried changing ir-led and photo transistors but can't get this done. i removed my ir-led and put a normal led and it light up, but ir-led does not work. can you please help me. i have attached a photo of my cluster.

Will_W_76 (author)  AmilaR13 hours ago


It appears that you got your IR LED and photo-transistor mixed up. The IR LED should be on its own side with the 220Ω resistor. The photo-transistor should be connected to the LED. Refer to Step 1 again. Hopefully this helps. Let me know if you have anymore questions!

Charlottehf982 months ago

Hi! I love your design, it's awesome! I've made it for an engineering project for college. I just have a couple of questions. Could I use capacitors to extend the amount of time that the LED remains on for once I remove my hand from near the circuit? And if so, how could I integrate this into the circuit itself (i.e. where could I attach the capacitors)? Great tutorial, thanks for posting it!

Will_W_76 (author)  Charlottehf982 months ago

Yes, that would work! The capacitor should be connected at the anode of the LED in that scenario.

AndreyG12 months ago

Thank you very much for sharing this, im new in instrucables :D

i have trouble here, why my led dim when i put my hand close to the clusters ?

Will_W_76 (author)  AndreyG12 months ago

That could be caused by a variety of things. First, what are you using as a power source? If you are using batteries, what batteries and what voltage are you using?

Second, it could be that your photo-transistor is not configured for the same wavelength of light that your IR LEDs emit. Make sure those are the same. My IR LED emits 880nm light, which is what my photo-transistor is configured to receive.

Another possible issue could arise from the resistor values you are using. Are you using the same values I am? Maybe check some of my responses to other users below about how to pick the right resistor values.

If none of these are helpful, post a picture or schematic of your circuit. I'll check it out and see if I can find the problem.

Thank you for your fast respond :D

Since im new in electronic i dont know what kind of wavelengh of my ir or phototransistor, my phototransistor is transparent colour, unlike your black

Im using 9v batt, im planning to use 12vbatt

My resistor are 47k and 220
Will_W_76 (author)  AndreyG12 months ago

Could you show me a picture of your circuit?

SuperPollo1 year ago

Nice, simple and cool, will definitely make it one day. There's one thing I don't understand, it's the 47k Ohm resistor. If you could explain to me, how does it help to direct the current ¿? And what's a pull-down resistor?

Will_W_76 (author)  SuperPollo1 year ago

That's a good question! To be able to give you a good explanation, I grabbed my voltmeter and did some trials with different resistance values. I included the schematics of these trials below. Check those out. It will help my explanation make more sense.

Before I get started with my explanation, I should mention that for simplicity I only included the photo-transistor and resistor in each of my schematics (the rest of the circuit is actually still there though, just not pictured).

Basically, larger resistors have larger voltage drops across them and smaller resistors have smaller voltage drops across them.

So look at the schematic on the left. Instead of the 47kΩ resistor, it has a 10Ω resistor. 10Ω is obviously significantly smaller than 47kΩ. Notice that when the photo-transistor is off, the voltage at node A (which is the voltage drop across the 10Ω resistor) is only 0.0006V, basically nothing. Even when the photo-transistor turns on, the voltage only increases to 0.0045V, still basically nothing. This is because the 10Ω resistor is so small, it will hardly have any voltage drop across it.

Look at the center schematic now. This one has the original 47kΩ resistor. Notice now that the voltage at node B is 0.817V when the photo-transistor is off and 8.24V when the photo-transistor is on. This is a great range! If you looked at the original schematic in the Instructable, remember that the LEDs anode is connected at what is labeled node B. So the LED "sees" this voltage too. The LED remains off at 0.817V, but would definitely turn on by 8.24V. So by having this voltage range, the LED is off when the photo-transistor is off. Then when an object moves over and turns on the photo-transistor, the LED turns on too.

Just to further explain how pull-down resistors work, look at the schematic on the right. This one has a 10MΩ resistor (this is a huge resistance). Since this resistor is so big, almost all of the voltage applied to the circuit drops across the 10MΩ resistor. You can see that the voltage at node C is 8.24V when the photo-transistor is off and 8.32V when the photo-transistor is on. Since the LED sees this voltage too, the LED would always be on regardless of if the photo-transistor is on or off.

So that's why I chose 47kΩ. If it were too small, the LED would never receive enough voltage to turn on. If it were too large, the LED would get too much voltage and always be on.

Finally, why are these referred to as pull-down resistors? Notice at the top of each schematic there is 9V from the battery. In the schematic on the left, the 10Ω resistor is very small and so there's not much voltage at our node of interest. But as we increase the resistance (to 47kΩ or 10MΩ) the voltage at our node of interest increases. So you can think of the larger resistors as "pulling" the voltage "down" to the node of interest.

I hope that makes sense! Please feel free to ask any other questions and thank you for your interest.

Pull-down resistor explanation.png
ilovegm Will_W_762 months ago

2 questions... I am quite confused with the actual application of transistors.

1) Why does a 10MΩ resistor cause the voltage to be so high when the phototransistor is off? Shouldn't there be no conductance from collector to emitter when transistor is off?

2) Does the emitter see a lower resistance when the LED and limiting resistor is connected? Due to addition of resistances in parallel?

Will_W_76 (author)  ilovegm2 months ago

1.) You're correct in thinking that there should be no voltage at the resistor when the photo-transistor is off. However, that is the IDEAL operation. No real-world component behaves according to it's theoretically ideal operation. Essentially, when a transistor is off, it acts kind of like a resistor (generally a very large one). You can usually find this "resistance" in the data sheet for the transistor of interest. In the circuits of my response above, the 10MΩ is so much larger compared to the "resistance" of the photo-transistor, so most of the voltage drop is across the 10MΩ resistor instead.

2.) Towards the beginning of my first response, I mentioned that the new circuits I drew only show the resistor and photo-transistor, for simplicity. The other components were still connected as shown in the original Instructable, and the measurements I included in my first response were taken on the original circuit. So the measurements included the additional parallel components.

Let me know if you have anymore questions!

ukhan141 year 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)  ukhan141 year 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_765 months ago
thanks a bunch Will!
amazing explanation!
kshowell made it!5 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.96196 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.

kabanbenedek7 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)  kabanbenedek7 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: http://www.farnell.com/datasheets/1683594.pdf

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)  kabanbenedek7 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.

alexis.carlsen10 months ago

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.carlsen10 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_7610 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ö9 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ö9 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.1610 months ago

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

bergerab10 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!

nejo001710 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.111 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!

carlos66ba12 months ago

Nicely done.


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

1-40 of 64Next »