12 Key KeyPad
ATmega328P.pdf ( Register summary on p 428 )( In Sweden eg. Kjell & Co artikel 90650 )


Numeric keyboard with 12 keys is usually used for combination locks, such as entering the PIN. The keys are connected between three columns (C1 C2 C3) and four rows (R1 R2 R3 R4). If a key is pressed, there will be a connection between the corresponding column and row.
The keyboard is connected with 7 pins, and it may be difficult to choose which pins to use.
The program defines ( #define ) symbolic names for registers and pins so that it will be easier to change to other pins if necessary.
The function getchar_KeyPad( ) is blocking and is therefore waiting for any contact to
be pressed down.
The columns are outputs, one at a time is 0, the others are 1. The rows are inputs with the internal pullup resistors activated.
If any of the inputs read 0 then the corresponding key has been pressed.
The keyboard can provide mechanical contact bounces. These can be avoided with a delay.
The sample program echoes the keystrokes to Arduino's serial communication terminal window.
KeyPad12.txt
( for Arduino use code stored as: keypad12\keypad12.ino )
William Sandqvist william@kth.se