LED Senses and Displays Ambient Light Intensity Dhananjay V. Gadre (
[email protected]) & Sheetal Vashist (
[email protected])
September 14, 2006
1
Introduction
LEDs are commonly used for displaying information. Although not used frequently, modern LEDs can also work as photo-voltaic detectors. (Reference 1) An LED under reverse bias condition can be modeled as a light dependent current source in parallel with a capacitor. More the incident light, larger is the current source value and that discharges the equivalent capacitor faster. Figure 1 illustrates the use of LED as a sensor. The LED is reverse biased, using two pins (pin1 and pin2 in the figure) of a microcontroller, which charges the equivalent capacitor. Subsequently, the cathode of the LED is connected an input pin (pin 3) of the Microcontroller. The capacitor which was charged to Vcc, will now discharge through the current source and when the voltage on the capacitor falls below the lower logic threshold, Pin3 of the microcontroller will sense the logic as ’0’. If the incident light intensity is more, the capacitor discharges faster and if the ambient light is less, it takes longer for the capacitor to discharge. Thus by measuring the time it takes for the voltage on pin 3 to reach logic ’0’, the microcontroller can estimate the intensity of the ambient light incident on the LED.
2
Circuit Operation
Figure 2 shows the circuit schematic of an AVR ATTiny15 based circuit that uses a 3-mm, red LED in a clear packaging, to sense the ambient light as well as to indicate the incident light intensity by flashing the same LED at a proportional frequency. The circuit is very simple and just uses 4 components. The power supply to the circuit can be any voltage between 3 to 5.5V DC. The LED is connected to port pins PB0 and PB1 of the AVR Microcontroller. Another port pin PB3 is used to output a square wave, with a frequency proportional to the incident light intensity. 1
Microcontroller Pin1
LED Vcc Pin2
Input Pin3
Figure 1: Using LED as a sensor. The circuit operates by first forward biasing the LED for a fixed period. It then reverse biases the LED, by changing the bit sequences applied to PB0 and PB1. In the next step, PB0 is then reconfigured as an input pin. An internal timing loop is used to measure the time it takes for the LED to change the logic voltage applied to PB0 from logic ’1’ to logic ’0’. This time T, is inversely proportional to the ambient light incident on the LED. The LED is then flashed at a frequency inversely proportional to the time T. Thus for lower light levels, the LED flashes at a lower frequency. As the incident light intensity increases, the LED flashing frequency increases. This provides a visual indication about the incident light intensity. Vcc (3 to 5.5V)
ATTiny15
Square Wave Out
10uF/16V
PB3 (3) Vcc(8) C1
100Ohm
Fout
PB1 (6) R1 D1
GND(4) PB0 (5)
Figure 2: Schematic Diagram
3
Testing
The circuit was tested by applying known light intensity through a test LED. For low values of LED forward current, the light output intensity is fairly linear (Reference 2). The light output of the test LED was coupled to the sensor LED (D1 in figure 2) of the circuit. It was ensured that no other 2
external light was incident on the sensor LED, by enclosing the test LED and the sensor LED in a sealed tube, covered with black tape. The test LED current was varied between 0.33 mA to 2.8 mA. Corresponding output of the sensor LED flashing frequency was recorded and is shown as a plot in figure 3. As can be seen from this figure, the circuit provides a fairly linear output.
Figure 3: LED Sensor output as a function of Ambient Light Intensity The ATTiny15 AVR Microcontroller is an 8-pin device. The circuit presented here uses only 3 out of the 6 I/O pins. The rest of the pins can be used to control external devices or for communication with other devices. Control program for the microcontroller was written in AVR assembly language and is enclosed.
4
References: • Reference 1: Paul Dietz, William Yerazunis, Darren Leigh, ‘Very Lowcost Sensing and Communication Using Bi-directional LEDs’, http://www.merl.com/reports/docs/TR2003-35.pdf • Reference 2: Garry Petrie, ’The Perfect LED Light’. http://www.resurgentsoftware.com/perfect led light.html
3