Proximity-Sensing LEDs

83K550116

Intro: 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

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.

STEP 2: Gather the Materials

This circuit consists of "clusters" that are in parallel. Since the clusters are in parallel, this means you can add as many as you want without the LEDs getting any dimmer! You could have 1000 clusters if you wanted to and every LED would be just as bright! (Your battery wouldn't last very long though.) For my implementation I used 24.

For each cluster you will need:

  • Photo-transistor
  • IR LED
  • LED of any color
  • 2 x 220Ω resistors
  • 47kΩ resistor
  • A couple small wires

Note: Photo-transistors and IR LEDs are available at different wavelengths. You don't have to use 880nm as I mentioned in the previous step. For best results though, use photo-transistors that are made to respond best to the wavelength that your IR LEDs emit.

For the rest of the circuit you will also need:

  • A breadboard (I'm using 3. Use as many as you like!)
  • A power source and connector (not pictured)

For a power source I'm using a 9V battery because I had one at my desk already. You have a lot of other options here though such as a 6V lantern battery or 4 AA batteries.

STEP 3: Connect Power Rails

I like to start by getting all of my power and ground rails connected. Just as you can see in the picture above I connected all of my positive (red) rails and negative (blue) rails. I also plugged in my battery connector, but I'm leaving the battery out until the end so there's no current through the circuit while I'm building it.

STEP 4: Build the First Cluster!

I prefer to start with building one cluster to test my design.

Note: Remember that the photo-transistor is not an LED. However, since it looks like an LED I will refer to its pins as anode (+) and cathode (-) for simplicity. I also included an image above that shows how to determine which pin is the anode and which is the cathode. I also included the circuit schematic, an animated breadboard image, and a photo of my circuit for reference.

  1. Connect the "anode" of the photo-transistor to the positive power rail.
  2. Connect the 47kΩ resistor from the cathode of the photo-transistor to ground. This resistor acts as what's called a pull-down resistor. It helps direct the current to where we want it to go.
  3. Also connect the cathode of the photo-transistor to the anode of the blue LED.
  4. Connect the cathode of the blue LED to ground with a 220Ω resistor.
  5. On the other side of the "valley" of the breadboard, connect the anode of the IR LED to the positive rail.
  6. Connect the cathode of the IR LED to ground with a 220Ω resistor.

If you would like, go ahead and connect your power source and test it out!

(If it's not working, see the final step for troubleshooting procedures.)

STEP 5: Finish the Other Clusters

Now that you (hopefully) have a working cluster, add as many more as you would like! For me personally, I go faster if I go one component at a time e.g. add all the IR LEDs, then add all the photo-transistors etc. That's just my personal preference. Do what works best for you though. The design for each cluster is the same as how it was covered in the previous step.

I included some pictures of my progress above.

STEP 6: Try It Out!

Here's a GIF of my circuit in action. Try yours out! You can use just about any object: hands, rulers, books, etc.

Hopefully yours is working at this point, but if not I included some troubleshooting procedures in the next step.

If yours is working though, awesome! Post a GIF of it in the comments below! And feel free to post any comments/questions/suggestions.

One last thing, I mentioned that I originally built this circuit to eventually move it to a PCB so I could learn PCB design/layout. The PCB I made was a success and I'll be making the Instructable documenting my design process very soon! Thanks for checking this out!

STEP 7: Troubleshooting

Hopefully you won't need this step, but here it is just in case!

  • If your circuit isn't working, one thing you can check is if the IR LEDs are actually on. Because if we can't see light in the infrared range, how do we know the IR LEDs are actually on? There's a simple way to check this. Simply just connect power and then look at the IR LEDs through a camera (phone cameras work fine). Through a camera they'll look like regular LEDs lighting up. You can see in the picture above that it looks like a regular pink LED, but that's one of my IR LEDs.
  • It's also possible that you're not getting enough voltage at the anode of the LED. This would result from there being too high of a voltage drop across the photo-transistor. To minimize the voltage drop across the photo-transistor, increase the value of the pull-down resistor. By increasing the value of the pull-down resistor, the voltage-drop across the photo-transistor decreases because the internal resistance of the photo-transistor is smaller relative to the larger pull-down resistor. Increase it gradually though because if you put in too large of a resistor, the LED will always be on.

These are the most common issues you would run into with this circuit. If you come across other obstacles though, please comment and I'll get back to you quickly with a solution.

100 Comments

Has anyone got the OPEN schematic file that I can use to send to the folks that make the PCB? I just cannot get my head around Eagle software. I cannot figure out how to attach the PWR and GND holes at either end of the PCB :(
Hi, this project is really awesome :)
I am building the same way as your schematic and my LED doesn't want to turn on. I am using 9 volts, checked IR with mobile and IR working.
When I goes with my hand over cluster nothing happend. Just for test I tried with one powered IR in my hand and goes over photo-transistor and it light up. Can you please help me. I have attached a photo.

i have the same problem? Are our foto transistor wrong? What the data of the transistor?

thx for answer, Frank from germany

Do you know how far away and object can be before it won't be picked up?

I was wondering, do you know what type of glass suits for this project? I bought this side table at the Ikea with a glass panel inside it.. But all the LED's are on, even though there is nothing on the table.. When I take the LED's away from the glass everything goes off... Maybe this is the wrong type of glass..? Any ideas?

When i built the circut I got the opposite effect... the led would be on then turn off when the sensor was covered...

Depending on the specific photo-transistor you are using, the LED can turn on because of the photo-transistors response to light in your environment (sunlight or even fluorescent or incandescent light). What is likely happening is that these other light sources are "turning on" your circuit. Then when you cover it, the photo-transistor no longer sees the external light and turns off. Additionally, it appears that the light emitted from your IR LED is not the proper wavelength (or your IR LED is not on). Otherwise, the LED would remain on when covering the sensor. Verify your IR LED is actually on, and also make sure it emits the wavelength of light that the photo-transistor is best set to receive. Lastly, eliminate the source of external light that is currently turning the circuit on. If it's something else, you can let me know.

Hi thanks for the response! Turns out I was using a photo cell not a transistor so it was looking for all light. From what you were saying that seems like it could have effected the out come.
Thanks again!

Using a 12V battery should be fine. You will just want to double-check that each of your components can withstand the voltage and current they will experience. You can find this information in the datasheet for each component. If it looks like there may be an issue, you can increase the 220Ω resistors (the current-limiting resistors) to a value that will ensure a safe level of operation.

Oh also I was wondering if there was a way to modify this circuit so it could use a 12v battery as a power source

If i do this larger scale, say for a 2' x 3' table. Is it possible to solder each individual "part" together according to your circuit diagram (with the "part" being one complete iteration of the diagram itself)? From here connect all of the ground ends together and then running it as a single unit into the ground of an arduino, and the same for the power ends. the only thing i can't wrap my head around is how the resistors would still work the same

Yes, that can be done. The main thing you would want to verify is how much current you are using though. With each "cluster" you are adding additional current to your circuit. Soldering together individual clusters that share a ground and power line is fine, there would be no reason the resistors wouldn't work the same way (as long as they were wired properly in their individual portion).

This is your scratch right?
If yes then can I use 12v or 5v instate of 9v. If I can what OHM or Kohm resister I need. Thanks

Since the "clusters" are all connected in parallel, you only need enough voltage to get across one LED, usually around 2V. The concern would be whether or not your battery can supply enough current for the number of clusters you include. To answer your question, yes, 5V and 12V will both work.

In regards to your question about resistors, this is more dependent on the other components of the circuit (the LED, photo-transistor, IR LED) than it is on the power supply. I would suggest choosing your power supply and components, then experimenting with a variety of resistance values.

Also, just want to give you a heads up, the way you drew the blue LED in your picture is backwards. The anode (positive side) of the LED should be connected to the junction of the 47kΩ and the emitter of the photo-transistor. This is because the LED receives power from the emitter of the photo-transistor.

Hello
I really like your projact and I would like to make one for myself. I tryed to make one but it wasn't work!! Can you clear me the connection that you did. I saw your picture but it's not clear to me . If you help me then I can make one like your. Thanks

Which connection are you having trouble with?

Without knowing more specifically, I can only suggest that you verify your LEDs have the correct orientation. Also, verify that your IR LED is functioning by looking at it through a camera, and make sure it outputs the same wavelength of light as your photo-transistor is set to receive.

Hi, thanks for posting a fun project. I built my first cluster and it works in the dark, but my detector seems to be picking up visible light waves too, so LED stays lit with the lights on. I used a 940 nm detector and receiver (it was what I had). Is this common, or is just a bad part. Thanks, Jayne

Sorry for the late response. This can be a common issue. It of course depends on the wavelength of light that you could be getting from various sources (sunlight through a widow, incandescent bulbs, fluorescent bulbs, etc.) I would recommend determining what wavelength of light is in your environment and then finding a phototransistor configured for a different wavelength so the light for the environment won't turn it on. (You will also need to get a different valued IR LED to match this new phototransistor.

Hello, I would like to firstly say that that this project looks really awesome however I'm at the very start of it... I was thinking of doing a simulation of it on a computer based software such as Yenka or Proteus to get a feel of how it works and so that I can mess about with it a bit before I order the required components, unfortunately I don't think Its possible to carry this out on a PC based simulation software because I cant make a link between the photo-transistor and the IR LED.

Have you got any suggestions or do you know of a way to do this / a work around from using the link between the photo-transistor and the IR LED just for simulation purposes ?

Thanks in advance! :)

I figured it out, you need to use a switch acting as the IR LED and then use a NPN transistor for the photo-transistor. Connect the output of the switch to the base of the NPN transistor. When the switch is pressed the current will flow to the base of the transistor and so making the LED light up.

More Comments