Use dual-color LED to indicate 10 states

Publisher:bullfishLatest update time:2011-06-17 Source: 自动化在线 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Most devices that use a microcontroller have several operating states. These states are usually controlled by a pushbutton switch. To minimize cost, many designs use a single switch; the number of times the switch is pressed determines the state of the microcontroller. The circuit in this article uses a lighted LED to indicate the selected state.

There are a large number of bi-color LEDs available in the market in various shapes and colors, from manufacturers such as Kingbright, Optosupply, etc. These LEDs provide new opportunities to indicate 10 states with just one LED. The state can be set by pressing a push button switch connected to the external interrupt pin of the microcontroller (Figure 1). Each time it is pressed, the interrupt routine sets the device to the next state (Figure 2).

State 0 is standby mode, with the LED off. The device is waiting for the switch to be pressed. The LED color indicates the following three states. For example, Kingbright's WP5A9EGW12.3SF LED can emit red, green, and orange colors. Adding flashing can indicate the remaining states. The red and green LEDs can be controlled independently to obtain six indication combinations (Table 1).

The microcontroller's internal oscillator is used as the clock source, which simplifies the circuit because the oscillator requires no external components and its 5% tolerance is sufficient for this application. The firmware sets the built-in pull-up resistor for the external interrupt input.

The clock speed, along with the prescaler value and the clock counter modulo register, determines the rate at which the LED blinks. The internal oscillator generates a 12.8 MHz clock, resulting in a 3.2 MHz bus frequency, with each cycle equal to 0.3125 μs. By choosing a prescaler value of 64, the time counter modulo register calculates one cycle as 50 times the timer period in milliseconds. For example, to get a 1 second blink rate, set the time counter modulo to 50000, or $C350 in hexadecimal.

Using a list instead of a program polling method can greatly reduce the size of the firmware. The assembly code of the firmware can be downloaded here. This method can be used for any microcontroller. Even different blink rates can be used to increase the number of indicated states.

Reference address:Use dual-color LED to indicate 10 states

Previous article:Analysis on the distribution and trend of control signals on the LED display unit board
Next article:Error Analysis in Long-range Testing of LED Street Light Characteristics

Latest Power Management 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号