Many robotic applications require a sen-sor to measure light levels. The conven-tional approach as shown in Figure 1 uses an A/D converter to measure the voltage drop across resistor R1 produced by the photo current through a photo transistor. The fixed value of R1 limits the light range which can be measured; a high resistor value is suitable for measuring low light levels while a low resistance is good in bright conditions. The resolution of the A/D converter also plays a part in deter-mining the range of light levels that can be measured. A little-used property of a standard LED is its reverse-biased photocurrent mode. An LED also produces a light-induced photocurrent but at a much reduced value compared to a photo-transistor.
Direct measurement of the current is not so easy but another property of the diode can be exploited which is described in [11. In this paper it explains that a useful property of a reverse-biased LED is its relatively large capacitance, the technique is to charge up this capacitor and then allow the photo-current to discharge it. The time taken for the capacitor to discharge is dependant on the amount of light falling on the LED (Fig-ure 2). Charging and time measurement can be easily performed using a single I/O pin of a microcontroller and switching it between output mode and high-imped-ance input mode. The measurement is performed in two stages: 1. The pin is configured as an output and set to high to charge up the LED capaci-tance (Figure 3). 2. The pin is configured as an input Pin (any pull-up resistor is disconnected) and the time is measured until the input voltage level falls below the lower input threshold level (Figure 4). The Example program is a listing for an Atmel AVR processor which measures light intensity.
The program toggles all the output bits from port A after each cycle so that it produces an output square wave with approximately 50 % duty cycle at a frequency proportional to the measured illumination. The frequency varies from millihertz (in a darkened room) up to sev-eral hundred kilohertz when light shines directly onto the LED. This measurement range would be difficult to achieve using an A/D converter. Narrow beam LEDs have a corresponding narrow ‘detection angle’ making them more directional which may be beneficial in some applications. Differ-ent LEDs are sensitive to specific colours which can also be useful in some robotic applications.