Monday 9 September 2019

Detecting light with an LED



How do I detect light with an LED?



Answer



It is possible to use a led as a light sensor as well as a light emitter. Essentially a reverse biased led will act as a capacititor, if it is then disconnected the charge will drain at a rate roughly proportional to the light hitting it.


We can use this with a microcontroller - utilising the multi state ability of the ports. alt text


The resistor should be about 100 ohms, I have only used this with red leds - it may work with others.


Use the following sequence:


Set Port A output high
set Port B output low // this makes sure the led is discharged
wait 1mS
set Port A output low

set Port B output high // reverse bias and charge
wait 1mS
set Port B as input // Port B is high impedance input
time how long for Port B to read low

The length of time will be dependant on the amount of light hitting the led.


There are several examples of this on the web - I will list them here as I find them again:


LED senses and displays ambient-light intensity


Red LEDs function as light sensors


Multi-Touch Sensing through LED Matrix Displays - very cool video



LEDs As Sensors


Very Low-Cost Sensing and Communication Using Bidirectional LEDs


No comments:

Post a Comment

arduino - Can I use TI's cc2541 BLE as micro controller to perform operations/ processing instead of ATmega328P AU to save cost?

I am using arduino pro mini (which contains Atmega328p AU ) along with cc2541(HM-10) to process and transfer data over BLE to smartphone. I...