Single pin on microcontroller to detect ambient light and control lighting

Publisher:真瓷堂Latest update time:2011-09-21 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

A previous Design Idea (Reference 1) used an LED as a transducer to measure ambient light intensity and provide illumination. This Design Idea uses the same principles, but only has an LED, two resistors, an IC, and a 0.1mF bypass capacitor. No additional components are required when the circuit is used to provide ambient light feedback. Although the circuit in Figure 1 requires only a few components, it still has considerable flexibility because the microprocessor software controls the brightness of the LED and its relationship to the ambient light level. For night-time lighting applications, one mode can illuminate the LED when the ambient light decreases. Conversely, for power-saving adjustment of the LCD backlight in a portable device, a second mode can illuminate the LED when the ambient light level increases.

Table 1 shows the sample code for this design example, which can be downloaded and provides 64 levels of PWM (pulse width modulation) intensity control for the brightness of the LED in both modes. When used, a multifunction pin of the microprocessor drives the LED with a PWM waveform for hundreds of milliseconds. After the last cycle of the waveform, the software switches the microprocessor pin to input mode and connects the LED to the microprocessor's internal 16-bit S-ΔADC. Ambient light generates a voltage on the LED, which is measured by the ADC and the microprocessor calculates the PWM waveform parameters for the next series of illumination cycles. Because the cycle rate has a high repetition rate, any visible flicker on the LED is eliminated.

The entire circuit consists of an LED, a microprocessor, two resistors and a capacitor.

In the table, when the software and the ambient light level determine that the LED should be turned off for an extended interval, the CPU enters a low power state for 250 ms. During this sleep mode and the hundreds of microseconds while the ADC conversions are being made, the circuit consumes only about 20 mA, making it ideal for battery-powered systems.

At startup, the microprocessor stores the initial voltage produced by an LED and uses this value to convert the PWM level. Shading the LED or moving the circuit to a dark area instantly increases the brightness of the LED, which is controlled in small steps by the 64 PWM levels in the table. The ADC input impedance of the MSP430F2013 is about 200 kΩ. When driving this impedance, the LED occupying the footprint of a 0805 surface mount package only produces a few tens of millivolts. However, the MSP430F2013's 16-bit ADC has enough resolution to resolve the LED voltage to ensure good performance under normal room light intensity.

Sample Code

In addition, the MSP430F2013 contains a four-stage PGA (programmable gain amplifier) ​​that provides gains of 1, 4, 8, and 16, further amplifying the tiny output voltage of the LED. The circuit also uses the microprocessor's on-chip low-frequency clock oscillator to run at low power without an external crystal. The final circuit has only six components, including a battery. It is worth noting that the code can be executed on the Texas Instruments eZ430 demonstration board without hardware modification because the board contains an LED connected to port P1.0.

Reference address:Single pin on microcontroller to detect ambient light and control lighting

Previous article:ADuC7128 realizes wideband phase measurement system
Next article:Design of multi-channel temperature acquisition module with DAC output

Latest Test Measurement Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号