Datasheet
program Keypad_Test;
var kp, cnt, oldstate : byte;
txt : array[6] of byte;
// Keypad module connections
var keypadPort : byte at PORTB;
var keypadPort_Direction : byte at DDRB;
// End Keypad module connections
// Lcd pinout definition
var LCD_RS : sbit at PORTD.B2;
LCD_EN : sbit at PORTD.B3;
LCD_D4 : sbit at PORTD.B4;
LCD_D5 : sbit at PORTD.B5;
LCD_D6 : sbit at PORTD.B6;
LCD_D7 : sbit at PORTD.B7;
var LCD_RS_Direction : sbit at DDRD.B2;
LCD_EN_Direction : sbit at DDRD.B3;
LCD_D4_Direction : sbit at DDRD.B4;
LCD_D5_Direction : sbit at DDRD.B5;
LCD_D6_Direction : sbit at DDRD.B6;
LCD_D7_Direction : sbit at DDRD.B7;
// end Lcd pinout definitions
begin
oldstate := 0;
cnt := 0; // Reset counter
Keypad_Init(); // Initialize Keypad
Lcd_Init(); // Initialize Lcd
Lcd_Cmd(LCD_CLEAR); // Clear display
Lcd_Cmd(LCD_CURSOR_OFF); // Cursor off
Lcd_Out(1, 1, 'Key :'); // Write message text on Lcd
Lcd_Out(2, 1, 'Times:');
while TRUE do
begin
kp := 0; // Reset key code variable
// Wait for key to be pressed and released
while ( kp = 0 ) do
kp := Keypad_Key_Click(); // Store key code in kp variable
// Prepare value for output, transform key to it's ASCII value
case kp of
//case 10: kp = 42; // '*' // Uncomment this block for
keypad4x3
//case 11: kp = 48; // '0'
//case 12: kp = 35; // '#'
//default: kp += 48;
251
MIKROELEKTRONIKA - SOFTWARE AND HARDWARE SOLUTIONS FOR EMBEDDED WORLD
Libraries
mikroPASCAL PRO for AVR
CHAPTER 6