Features
• • • • • • • • 16 Key Pushbutton Pad in 4 x 4 Matrix Very Low Power Consumption AVR in Sleep Mode and Wakes Up on Keypress Minimum External Components ESD Protection Included if Necessary Efficient Code Complete Program Included for AT90S1200 Suitable for Any AVR MCU
8-bit Microcontrollers Application Note
PRELIMINARY
1 Introduction
This application note describes a simple interface to a 4 x 4 keypad designed for low power battery operation. The AVR spends most of its time in Power-down mode, waking up when a key is pressed to instigate a simple test program that flashes one of two LEDs according to the key pressed. If “0” (zero) is pressed the RED LED flashes 10 times. All other keys flash the GREEN LED the number of times marked on the key (e.g., if “C” is pressed the GREEN LED flashes twelve times). Figure 1-1. Keypad and LED Connections
AT90S1200
R1 PB7 R2 PB6 R3 PB5 C1 C2 D1 R1 D2 R2 D3 R3 D4 R4 ALL 1N4148 1 4 7 A C3 2 5 8 0 C4 3 6 9 B F E D C R4 PB4 R5 PB3 R6 PB2 R7 PB1 R8 PB0 ALL 470Ω PD0 ALL 330Ω PD1 R9 PD2 R10 LED2 GREEN LED1 RED VCC
4 x 4 KEYPAD
Rev. 1232D-AVR-06/06
2 Theory of Operation
The keypad columns are connected to the high nibble of port B. The keypad rows are connected to the low nibble. Resistors R1 to R8 (this is shown in Figure 1-1) serve to limit input current to a safe level in the event of ESD from the keypad. They can be omitted in most applications. In the steady state condition the high nibble is configured as outputs and are in the low state. The low nibble is configured as inputs and has the internal pull-ups enabled, removing the need for external pull-up resistors. After initialization the AVR is put to sleep. When a key is pressed one of the diodes D1 - D4 pull down the external interrupt line PD2, which also has internal pull-ups enabled. This wakes up the AVR and causes it to run the interrupt service routine, which scans the keypad and calculates which