Two ways to use an LED as a light sensor with Arduino
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.
Have an amazing project to share? The Electronics Show and Tell is every Wednesday at 7:30pm ET! To join, head over to YouTube and check out the show’s live chat and our Discord!
Python for Microcontrollers – Adafruit Daily — Python on Microcontrollers Newsletter: A New Arduino MicroPython Package Manager, How-Tos and Much More! #CircuitPython #Python #micropython @ThePSF @Raspberry_Pi
EYE on NPI – Adafruit Daily — EYE on NPI Maxim’s Himalaya uSLIC Step-Down Power Module #EyeOnNPI @maximintegrated @digikey