Single pin on microcontroller to detect ambient light and control lighting

Publisher:点亮未来Latest update time:2013-07-04 Source: dzsc 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. When the circuit is used to provide ambient light feedback, it does not require additional components. 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-lighting applications, one mode can illuminate the LED when the ambient light decreases. Conversely, for power-saving adjustment of LCD backlights in portable devices, the second mode illuminates the LED when the ambient light level increases.

  Table 1 is the sample code for this design idea, which can be downloaded and provides 64 levels of PWM (pulse width modulation) intensity control for the LED brightness 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 across the LED, the ADC measures this voltage, and the microprocessor calculates the PWM waveform parameters for the next series of illumination cycles. Because the cycle rate has a high repetition frequency, 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 intensity determine the LED

 
When shutting down 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 performed, 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 calculate 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 produces only 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 levels.

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.

References
1. Myers, Howard, "Stealth-mode LED controls itself," EDN, May 25, 2006, pg 98.

2. MSP430F2013 datasheet http://www.dzsc.com/datasheet/MSP430F2013.html.

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

Previous article:Micro home electrocardiograph based on MSP430
Next article:CDMA wireless terminal with built-in TCP/IP protocol

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号