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.
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
- Popular Resources
- Popular amplifiers
- MathWorks and NXP Collaborate to Launch Model-Based Design Toolbox for Battery Management Systems
- STMicroelectronics' advanced galvanically isolated gate driver STGAP3S provides flexible protection for IGBTs and SiC MOSFETs
- New diaphragm-free solid-state lithium battery technology is launched: the distance between the positive and negative electrodes is less than 0.000001 meters
- [“Source” Observe the Autumn Series] Application and testing of the next generation of semiconductor gallium oxide device photodetectors
- 采用自主设计封装,绝缘电阻显著提高!ROHM开发出更高电压xEV系统的SiC肖特基势垒二极管
- Will GaN replace SiC? PI's disruptive 1700V InnoMux2 is here to demonstrate
- From Isolation to the Third and a Half Generation: Understanding Naxinwei's Gate Driver IC in One Article
- The appeal of 48 V technology: importance, benefits and key factors in system-level applications
- Important breakthrough in recycling of used lithium-ion batteries
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Material: RF Circuit Design - Theory and Application
- A Brief Analysis of Streaming Media Solutions Based on Embedded DSP
- Another TWS earphone charging box disassembly
- The official ST Chinese forum is now online. Let’s go and have a look.
- Qorvo Launches High-Performance BAW Filters to Support Band 41 5G Base Station Deployment
- It’s dangerous to make phone calls at a gas station, so is it safe to pay by scanning a QR code with your mobile phone?
- MSP430 MCU's own hardware SPI communication
- Is this description correct for the three working conditions of a transistor? To achieve these conditions, how should the peripheral circuit...
- Microstrip transmission line impedance matching engineering example
- 5-minute quick talk - Nichicon small lithium-ion rechargeable battery