Ask MAKE is a weekly column where we answer reader questions, like yours. Write them in to or drop us a line on Twitter. We can’t wait to tackle your conundrums!


This week’s question comes from Kevin:

I heard that you can use an LED as a light sensor. How?

LEDs are diodes tuned specifically to emit light and packaged in translucent enclosures. A photodiode is essentially the same thing, but sensitive to a wider range of light wavelengths. From the very informative Wikipedia page on the subject:

For example, a green LED will be sensitive to blue light and to some green light, but not to yellow or red light. Additionally, the LED can be multiplexed in such a circuit, such that it can be used for both light emission and sensing at different times. In Dietz et al., a scheme for implementing this multiplexing is presented:

  • A LED is connected to two bidirectional CMOS I/O pins on a microcontroller (or a microprocessor with an I/O bus).
  • To emit light, both of the I/O pins are set to output mode, and the LED is driven with current in the forward direction, resulting in current through the LED and emission of light.
  • To detect ambient light:
    • The I/O pins are set to output mode, and the diode is driven in the reverse-bias direction, such that the diode inhibits the current and the LED’s inherent capacitor is charged.
    • The I/O pins are set to high-impedance CMOS input mode.
    • The diode leaks current at a rate proportional to the incident light, as incident photons cause electrons to leap across the band gap.
    • The time it takes for this leakage current to discharge the LED’s inherent capacitor is measured and is inversely proportional to the incident light.

Don’t be intimidated by the electronics terms above, it’s actually pretty simple. Arduino has an example on their site showing a LED connected from one digital pin to another through a 100 ohm resistor. Part of the code tells the LED to light up, and part of it reverses the current and tells the former power pin to read the current leakage of the diode, which will change relative to the amount of ambient light in the room.

Here’s a short video showing a grid of red LEDs being used also as photodiodes (also photo above). Provolot tried it out, too, with success (and source code). Forest M. Mims III uses this technique to sense specific wavelengths of light for sun research in Hawaii.

Have you worked with LEDs as photodiodes? Share your project, video, or tips with us in the comments!

This week’s Ask MAKE has been sponsored by Jameco Electronics.