Two ways to use an LED as a light sensor with Arduino

From John Graham-Cumming’s blog:

If the LED is reverse biased (i.e. connected to a voltage source the wrong way round) then it won’t light up but it will act as a capacitor that charges when light hits it. So the idea is to reverse bias the LED using two digital pins on the Arduino (one set HIGH and one set LOW) and then remove the bias and measure how long the LED (acting as a capacitor) takes to discharge. The brighter the light the faster the discharge.

This can be achieved with a single LED connected between two digital pins like this: the +ve lead of the LED goes into the pin identified by LED_P and the -ve into the pin identified by LED_N.

Wow! Who knew!





Discover more from Unixism

Subscribe now to keep reading and get access to the full archive.

Continue reading