Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // include the library code:
- #include <Keypad.h>
- #include <LiquidCrystal.h>
- // initialize the library with the numbers of the interface pins
- const byte numRows = 4;
- const byte numCols = 3;
- char keymap[numRows][numCols]=
- {
- {'1','2','3'},
- {'4','5','6'},
- {'7','8','9'},
- {'*','0','#'}
- };
- byte rowPins[numRows]={6,5,4,3};
- byte colPins[numCols]={2,1,0};
- Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
- LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
- void setup() {
- // set up the LCD's number of columns and rows:
- lcd.begin(16, 2);
- // Print a message to the LCD.
- lcd.print("hello, world!");
- Serial.begin(9600);
- }
- void loop() {
- lcd.setCursor(0, 1);
- char keypressed = myKeypad.getKey();
- if(keypressed != NO_KEY)
- {
- Serial.print(keypressed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement