Advertisement
Guest User

Alarm Pt.1

a guest
Apr 26th, 2014
1,959
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.63 KB | None | 0 0
  1. /* The LCD circuit:
  2.  * LCD pin 1 to ground
  3.  * LCD pin 2 to 5V
  4.  * LCD RS pin 4 to digital pin 12  
  5.  * LCD R/W pin 5 to ground
  6.  * LCD Enable pin 6 to digital pin 11
  7.  * LCD D4 pin 11 to digital pin 5
  8.  * LCD D5 pin 12 to digital pin 4
  9.  * LCD D6 pin 13 to digital pin 3
  10.  * LCD D7 pin 14 to digital pin 2
  11.  * LCD pin 15 to 5v with 220ohm resistor
  12.  * LCD pin 16 to ground
  13.  *
  14.  * 10K pot:
  15.  *   one end to +5V and the other to ground
  16.  *   wiper (middle pin) to LCD pin 3
  17.  */
  18.  
  19. // include the library code:
  20. #include <LiquidCrystal.h>
  21.  
  22. // include the keypad code:
  23. #include <Keypad.h>
  24.  
  25. const byte ROWS = 4; //four rows
  26. const byte COLS = 3; //three columns
  27. char keys[ROWS][COLS] = {
  28.   {'1','2','3'},
  29.   {'4','5','6'},
  30.   {'7','8','9'},
  31.   {'*','0','#'}
  32. };
  33. //  keypad1 > pin13
  34. //  keypad2 > pin10
  35. //  keypad3 > pin9
  36. //  keypad4 > pin8
  37. //  keypad5 > pin7
  38. //  keypad6 > pin6
  39. //  keypad7 > pin0
  40. byte rowPins[ROWS] = {10, 0, 6, 8}; //connect to the row pinouts of the keypad
  41. byte colPins[COLS] = {9, 13, 7}; //connect to the column pinouts of the keypad
  42.  
  43. Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
  44.  
  45. // initialize the library with the numbers of the interface pins
  46. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  47.  
  48. void setup() {
  49.   // set up the LCD's number of columns and rows:
  50.   lcd.begin(16, 2);
  51.  
  52.   // Print a message to the LCD.
  53.   lcd.print("Enter code:");
  54. }
  55.  
  56. void loop() {
  57.   // set the cursor to column 0, line 1
  58.   // line 0 is the first row, line 1 is the second row
  59.   lcd.setCursor(0, 1);
  60.  
  61.   char key = keypad.getKey();
  62.   if (key != NO_KEY){
  63.       lcd.print(key);    // print keypress to LCD
  64.   }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement