COMPONENTS REQUIRED :
#include "Keypad.h"
#include <LiquidCrystal.h>
const int rs = 13, en = 12, d4 = 11, d5 = 10, d6 =9, d7 = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const byte Rows= 4; //number of rows on the keypad i.e. 4
const byte Cols= 3; //number of columns on the keypad i,e, 3
char keymap[Rows][Cols]=
{
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
byte rPins[Rows]= {4,3,2,A5}; //Rows 0 to 3
byte cPins[Cols]= {7,6,5}; //Columns 0 to 2
Keypad kpd= Keypad(makeKeymap(keymap), rPins, cPins, Rows, Cols);
void setup()
{
lcd.begin(16, 2);
lcd.setCursor(0, 0);
Serial.begin(9600); // initializing serail monitor
}
void loop()
{
char keypressed = kpd.getKey();
if (keypressed != NO_KEY)
{ lcd.print(keypressed);
Serial.println(keypressed);
}
Comments
Post a Comment