34
\$\begingroup\$

How do I detect light with an LED?

\$\endgroup\$
  • 5
    \$\begingroup\$ I've wondered about this, too. Can you make a display of an array of LEDs and then detect touch by using the same LEDs to sense reflected light from a finger? \$\endgroup\$ – endolith Dec 7 '09 at 20:26
39
\$\begingroup\$

It is possible to use a led as a light sensor as well as a light emitter. Essentially a reverse biased led will act as a capacititor, if it is then disconnected the charge will drain at a rate roughly proportional to the light hitting it.

We can use this with a microcontroller - utilising the multi state ability of the ports. alt text

The resistor should be about 100 ohms, I have only used this with red leds - it may work with others.

Use the following sequence:

Set Port A output high
set Port B output low   // this makes sure the led is discharged
wait 1mS
set Port A output low
set Port B output high  // reverse bias and charge
wait 1mS
set Port B as input     // Port B is high impedance input
time how long for Port B to read low

The length of time will be dependant on the amount of light hitting the led.

There are several examples of this on the web - I will list them here as I find them again:

LED senses and displays ambient-light intensity

Red LEDs function as light sensors

Multi-Touch Sensing through LED Matrix Displays - very cool video

LEDs As Sensors

Very Low-Cost Sensing and Communication Using Bidirectional LEDs

\$\endgroup\$
  • \$\begingroup\$ Utilizing the capacitance of the LED is indeed a clever way to detect light, and this is a great solution if you have a microcontroller. However, it works because an LED is a poor photodiode which is just a small photovoltaic panel. By measuring the time for the capacitance to decrease you are indirectly measuring this voltage. An analog solution could also amplify this small voltage, no reverse bias needed (but sometimes desirable for other reasons; see link). \$\endgroup\$ – Phil Frost Jan 16 '13 at 22:01
  • \$\begingroup\$ Why not leaving both A and B low to discharge the capacitor? \$\endgroup\$ – FarO Feb 27 '17 at 15:20
6
\$\begingroup\$

Here is a good video describing how LEDs can be used as a light sensor http://www.youtube.com/watch?v=VZUvoLDlMS0 Also Forest M.Mims III has wrote about simple projects using LEDs as touch sensors as well.

Also, I have read that SMD LEDs work better as light sensors than through hole LEDs...

\$\endgroup\$
2
\$\begingroup\$

Here is a circuit that uses a LED to detect light from an educational kit : LED light detector

LED 0 allows a very small , light-influenced current to pass through because its polarity is reversed.Make sure it is green , yellow or transparent or it may not work (red). The transistors amplify this current just enough to drive a normal polarized LED (LED 1).You can adjust the sensibility by adding more transistors , thus having a greater amplification , responding to a lower illumination level.

\$\endgroup\$
2
\$\begingroup\$

This site: http://www.users.waitrose.com/~robinjames/LED_as_light_sensor/LED_as_light_sensor.html shows how to measure light levels using an LED and an opamp, to give a voltage proportional to the light level. It gives a wide range of readings and works from complete darkness to full sunlight. It can be used to feed the ADC of a microcontroller such as an Arduino.

\$\endgroup\$
0
\$\begingroup\$

Photocells are a dead simple way to detect light. It's resistance varies proportionally to the amount of light shining on it.

LadyAda has a very nice write-up on photocells including Arduino implementation: http://www.ladyada.net/learn/sensors/cds.html.

\$\endgroup\$
  • 6
    \$\begingroup\$ The question was about LEDs! \$\endgroup\$ – Federico Russo Jun 14 '11 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.