Using an LED for a Light Sensor

Introduction: Using an LED for a Light Sensor

About: is a website devoted to people who want to make their own things and provide for their own needs. We provide information, encouragement and resources to empower people to become free from ...
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.
Electronics Tips and Tricks

Participated in the
Electronics Tips and Tricks

LED Contest with Elemental LED

Participated in the
LED Contest with Elemental LED

Be the First to Share


    • Pocket-Sized Speed Challenge

      Pocket-Sized Speed Challenge
    • Audio Challenge 2020

      Audio Challenge 2020
    • Maps Challenge

      Maps Challenge

    6 Discussions


    5 years ago

    Where is the rest of the tutorial?


    6 years ago on Introduction

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

    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.