Introduction: 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:
  • 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
The way you can do both sensing and emitting is to alternate between the two modes. Turn the LED on, then off, making a measurement, then back on. Repeat this sequence at least 100 times per second and you can't see any flicker. You are limited to short measurements, so practical applications will be limited, but it would be fun to play around with it. Using it as an illuminated touch switch will certainly impress your techie friends.

Comments

author
pedro.pfxr (author)2015-03-23

Where is the rest of the tutorial?

author
wblakesx (author)2014-06-15

Bravo

author
baudeagle (author)2013-07-23

Is this how they build optical isolation units for electrical controls?

author
amandaghassaei (author)2012-08-17

I'll have to give this a try sometime! Do you think this sensor is only sensitive to the wavelength that it emits? Must be.

author

try other wavelengths and see ;)

author
rimar2000 (author)2012-08-17

This is very interesting, thanks for sharing.

About This Instructable

7,665views

35favorites

License:

Bio: ProvideYourOwn.com is a website devoted to people who want to make their own things and provide for their own needs. We provide information, encouragement ... More »
More by ProvideYourOwn:Using an LED for a Light SensorAnalog Output - Convert PWM to VoltageHidden Arduino Thermometer
Add instructable to: