Zephyrnet Logo

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

Date:

John Graham-Cumming needed to log when a light switched on and off during the night as part of debugging an oddly behaving movement sensor. To do that a really simple light sensor logger was built using an Arduino Leonardo, a large LED and a resistor or three.

That light sensor via LED relies on the photovoltaic effect: when light strikes the PN junction inside the LED it creates a voltage (albeit a small one). But there’s another way to measure the light hitting an LED.

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.
See how in the post here.

spot_img

Latest Intelligence

spot_img