Advertisement
Guest User

Untitled

a guest
Nov 18th, 2014
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.83 KB | None | 0 0
  1. // include the library code:
  2. #include <Keypad.h>
  3. #include <LiquidCrystal.h>
  4.  
  5. // initialize the library with the numbers of the interface pins
  6. const byte numRows = 4;
  7. const byte numCols = 3;
  8.  
  9. char keymap[numRows][numCols]=
  10. {
  11.   {'1','2','3'},
  12.   {'4','5','6'},
  13.   {'7','8','9'},
  14.   {'*','0','#'}
  15. };
  16.  
  17. byte rowPins[numRows]={6,5,4,3};
  18. byte colPins[numCols]={2,1,0};
  19.  
  20. Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows, numCols);
  21.  
  22. LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
  23.  
  24. void setup() {
  25.   // set up the LCD's number of columns and rows:
  26.   lcd.begin(16, 2);
  27.   // Print a message to the LCD.
  28.   lcd.print("hello, world!");
  29.  
  30.   Serial.begin(9600);
  31. }
  32.  
  33. void loop() {
  34.   lcd.setCursor(0, 1);
  35.  
  36.   char keypressed = myKeypad.getKey();
  37.   if(keypressed != NO_KEY)
  38.   {
  39.     Serial.print(keypressed);
  40.   }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement