Market, a large number of optional two-color LED, a variety of shapes and colors, manufacturers such as Kingbright, Optosupply and so on. The LED provides a new opportunity, a LED can indicate only 10 states. Press a connection to an external interrupt pin micro-controller key switch, you can set the state (Figure 1). Each time you press, the interrupt routine will set the device to the next state (Figure 2).
State 0 is the standby mode, LED is off. Press the switch at this time waiting for equipment. LED colors indicate the following three states. For example, Kingbright's WP5A9EGW12.3SF LED may issue a red, green, orange color. With flashes can indicate the rest of the state. Red and green LED can be independently controlled, resulting in six indication combinations (Table 1).
Microcontroller's internal oscillator as a clock source, simplifying the circuit, because the oscillator does not require external components, the 5% tolerance sufficient for this application. Firmware to set the external interrupt input pull-up resistor built.
Clock speed prescaler and clock counter mode register values together determine the LED blink rate. A 12.8 MHz internal oscillator clock, to obtain 3.2 MHz bus frequency, each cycle is equal to 0.3125 μs. The prescaler value is selected as 64, the time counter mode register can be calculated as 50 times a cycle timer period (in milliseconds). For example, to get the blink rate 1s, should be time counter mode is set to 50000, or hexadecimal $ C350.
List instead of using the method of polling procedures, can greatly reduce the size of the firmware (Reference 1). Here you can download the firmware into assembly code. This method is applicable to any micro-controller. Can even use different blink rate, indicating an increase in the number of states.