Instructables
Picture of Better LED as light sensor
As a result of the questions from lekirst  on this ible of my hand: LED-as-lightsensor-on-the-arduino/ and the cleaner code made by hansc44 at:  Arduino-Use-LED-as-a-light-sensor/ it was time to come with a better Ible. So here it is. (I didn't solve lekirst's problems yet so she probably is open for suggestions)

What is the idea?

You might know that a LED emits light when you put the right amount of volts on the right leads. The funny thing is that it also works the other way around. Not the leads, it doesn't work when you put the leads the other way around. But what does work is that when you shine light on a LED it will GIVE current. It is a very small current but just enough for an Arduino to detect.

What will it do?

When you darken the sensor led, for instance by covering it with your hand, it will turn on the other LED.

Does this work with any LED?

As far as I know, it works with any LED, but not with any LED as good.
green and red LEDs seem to work best.
If trough experimenting you find out that other colors even work better, let me know.

Does it work with any light?

This sketch works very reliable with normal daylight. It is not fully tested in dark rooms or bright sunlight yet.

 
Remove these adsRemove these ads by Signing Up

Step 1: You will need

Picture of You will need
You will need
  • an Arduino board (Uno, Duemilanove or something like that)
  • two LEDs
And really that's it! (you could even do it with just one LED and use the SMD-LED on the Arduino board as the second LED)

You will need no tools.

You do need a computer with the Arduino software installed and a USB-cable to connect the Arduino board. (But if you have an Arduino board, you probably have that sorted already)

WX4ME6 months ago

Great enhancment

please keep going further

can you tell me how can i make it sense more than one LED like putting 2 more sensing leds and operate the same ?

thanks a lot

kenyer (author)  WX4ME6 months ago

You can use as many sensing led's as you have analog ports at your disposal. Just be sure to use shielded wire to connect them. If you don't use shielded wire the interference in the air might confuse the Arduino.

WX4ME kenyer6 months ago

Thanks for fast replay.

What i mean is that the code will be different, i tried to add more LEDs and modify the code in the Arduino software but i cannot make it for 2 more led sensors please help me doing it for total of 3 leds and 3 digital output(each LED sensor has its own digital output).

Thanks again

kenyer (author)  WX4ME6 months ago

Can you send me the code you wrote? So I can see what went wrong. You might use personal mail for that.

WX4ME kenyer6 months ago

kindly waiting for your email

have a good day

kenyer (author)  WX4ME6 months ago

I can't find where you send the code.

swolf119 months ago

nice! i made it and is working nice!

kenyer (author)  swolf119 months ago
cool! are you using it for something special?
KevinGames11 months ago
I do not know what happened, but when I back anywhere on the board until the blue side and the LED flashes
kenyer (author)  KevinGames11 months ago
What do you mean with "when I back anywhere on the board until the blue side"?
Using an Arduino for this is a waste of a million transistors. Use the LED to turn on another transistor used as a simple switch. That could cost less than $1. Add a relay or higher current transistor, SCR, Triac or whatever for higher current.
kenyer (author)  emerson.john1 year ago
To get this working for less than 1,- and without all the code, that would be really great. If you get it working, please post the schematics and/or write an Ible about it. I would be really interested in that schematic. (I do know that I can easily do this with an ATTINY45, but that is still the same as this, just with a cheaper IC)
I have tried to post a reply with a schematic attached, but every time I attempt to upload the schematic (a .jpg file) it deletes my explanatory comments, as it is failing to upload the file.
I decided to use an op-amp instead of a transistor because of the enormous gain and other features available with op-amps, and their ridiculous low price ($0.13 for an LM358AN, for example). The circuit also requires 3 resistors, and that's all. I'll try again another day.
Amazing project! Good job.
The setup is so sensitive that it works off the electrical pulses off my hand when I touch the analog pin.
kenyer (author)  Aj Creations1 year ago
That would be a nice follow-up project :)
redrok1 year ago
Hi Kenyer;
Pretty much all LED work as Photo Voltaic sensors. All the way from InfraRed to UltraViolet.

Nick Holonyak, http://en.wikipedia.org/wiki/Nick_Holonyak,
and Oleg Losev, http://en.wikipedia.org/wiki/Oleg_Losev,
who invented LEDs understood their PV action, but it was generally not know in the industry.
Later, Forrest Mims, http://en.wikipedia.org/wiki/Forrest_Mims,
is credited with the “Mims Effect”.

My own work is with using LEDs in solar trackers.

redrok
kenyer (author)  redrok1 year ago
Thank you for this info and links. I didn't know this about Mims. Do you have a link to the solar trackers you work with?

I did know that all LEDs (that I tested) work, but not all LEDs give the same result. Some LEDs give a much higher range than others. Until now, green is my personal favorite.
shortw kenyer1 year ago
I have been on redrok's wonderful and informative website.
It is redrok.com

LEDs work by having a band gap corresponding to the wavelength of light that they emit. Electrons drop from higher potential (caused by applying a voltage) to a lower potential, the 'height' determined by the band gap, they lose this energy by emitting a photon. No electrons can exist in an intermediary energy level so you get a single wavelength of light emitted (formula wise, band gap energy = planck's const. x light frequency ). The reason we've only had certain colour LEDs more recently, blue, for instance is due to better understanding of semiconductors and how to fabricate them.

The inverse is also true - when you shine light on an LED, you're exciting electrons in the valence band. If you give them sufficient energy to jump the band gap, then they will and you'll see the effect as a current. The caveat is that only photons with energy greater than the band gap will cause conduction. You'll probably find that infrared LEDs work best due to their smaller band gap compared to say UV.

This is identical to the way that a standard silicon (or whatever) photodiode can produce a current from incident light. The difference is that the bandgaps involved in these semiconductors are non-radiative - they don't emit light when you put a potential difference across them.

And of course this means you can never get a truly white LED. You have to mix different band gap semiconductors to approximate the light. Tungsten, by comparison has a very broad spectral output, but this is simply due to black body radiation (and therefore has a main peak that roughly correlates with its temperature, so you can make 'cool' or 'warm' lighting easily).
Numbers wise, a GaAs red led has a bandgap of around 1.4eV, corresponding to 875nm, or 'red'. A silicon photodiode has a bandgap of 1.1eV which goes to 1100nm. So any light 'redder' than this won't be absorbed because the electrons can't be raised to a high enough energy level (think about jumping next to a cliff, if you jump high enough from the ground you can reach the top, but there's nowhere to stop inbetween).

There'a an upper limit too, due to the quantum efficiency of the material. This tells you how many electrons are produced per incoming photon. As you go shorter, the response of the detector gets worse. This is a pretty good diagram for a silicon solar cell:

http://pvcdrom.pveducation.org/CELLOPER/Images/QE.gif
Clear LEDs will usually work better than colored or frosted ones. Also avoid the white ones. The phosphor will produce higher losses. While it is interesting that LEDs can be used as light detectors, for practical designs it is best to use a photodiode.
rimar20001 year ago
Very good work. Maybe it could enhance if you isolate visually both LEDs, because the red light incides on the white LED when you darken it.
Forrest Mims, let me give you a lot of credit for my early interest in LEDs all those years ago.
An interest that now builds the mother of all mother, futuristic LED displays.
https://www.facebook.com/#!/wayne.masters.35
djdreamz1 year ago
I can see someone creating a solar panel made of LEDs. Great instructable.
armstk1801 year ago
Nice Job man !

P.S: Doing Electronics was ad are my best friend in my whole age , It is also my job for more than 10 years
Enjoy electronics my friend for ever !

Take Care .... Mohammad
k5cfw1 year ago
Connecting an LED to a digital output port, without an added series current-limiting resistor, will stress and potentially damage the output port. In engineering terms, it violates Kirchoff's voltage law, particularly for LEDs with a lower forward voltage (like red). For a short-term experiment, you can probably get by with it. But in the long term, add the resistor to keep the Arduino (and your LED) within their designed safe operating region.
kenyer (author)  k5cfw1 year ago
This is very true! Pin 13 on the Arduino is the exemption on this rule because it has a resistor build in what makes it very handy for easy experiments like these: http://playground.arduino.cc/uploads/Main/arduino_notebook_v1-1.pdf

Still it is very good that you mention this.
edorphy1 year ago
Your LED is going to pull too much current. Put in a 330 ohm or larger resistor to decrease the current.
kostya1 year ago
Nice project! I've read orange LEDs are the best as light sensors.
kenyer (author)  kostya1 year ago
Thank you for the info, I will try that.