Using an LED for a Light Sensor
by ProvideYourOwn in Circuits > Electronics
8895 Views, 37 Favorites, 0 Comments
Using an LED for a Light Sensor
Until recently, CdS (Cadmium Sulfide) photo-resistors have been commonly used for light sensing applications. Unfortunately, they have problems. Since CdS cells contain cadmium, a toxic heavy metal, they present a disposal problem. As a result they are also becoming difficult to find from common electronics distributers.
Fortunately, there is a simple and very inexpensive alternative - the LED. Not only can an LED be used to sense light, but by clever use, it can function as both a light detector as well as an emitter.
How to use it for a light sensor
The reason an LED works for light sensing is that it contains a small amount of parasitic capacitance when connected in reverse. When this capacitor is charged, it will leak and lose its charge in proportion to the amount of light falling on the LED. Here's how to make use of this effect:
1) Connect it in reverse to a microprocessor I/O pin. See the second photo.
2) Set your pin to the HIGH state. Wait a millisecond to charge the parasitic capacitor.
3) Set the pin to the LOW state, then turn off your pull-up resistor. This will begin to drain the capacitor.
4) Measure the time to discharge the capacitor. The stronger the light, the faster the discharge.
These steps should work on any microprocessor. I have written a more complete article on this technique including code for the Arduino that should make these steps clearer.
Dual Mode - Sensing & Emitting
You can use this technique for some novel applications. Here are a few:
Fortunately, there is a simple and very inexpensive alternative - the LED. Not only can an LED be used to sense light, but by clever use, it can function as both a light detector as well as an emitter.
How to use it for a light sensor
The reason an LED works for light sensing is that it contains a small amount of parasitic capacitance when connected in reverse. When this capacitor is charged, it will leak and lose its charge in proportion to the amount of light falling on the LED. Here's how to make use of this effect:
1) Connect it in reverse to a microprocessor I/O pin. See the second photo.
2) Set your pin to the HIGH state. Wait a millisecond to charge the parasitic capacitor.
3) Set the pin to the LOW state, then turn off your pull-up resistor. This will begin to drain the capacitor.
4) Measure the time to discharge the capacitor. The stronger the light, the faster the discharge.
These steps should work on any microprocessor. I have written a more complete article on this technique including code for the Arduino that should make these steps clearer.
Dual Mode - Sensing & Emitting
You can use this technique for some novel applications. Here are a few:
- An LED that turns on/off when touched (works only in well lit conditions).
- An LED whose brightness varies in proportion to ambient lighting
- Bi-directional communications using a single LED for transmitting & receiving