]> git.piffa.net Git - sketchbook_andrea/blob - hardware/keypad/keypad_ino/keypad_ino.ino
RF e keypad
[sketchbook_andrea] / hardware / keypad / keypad_ino / keypad_ino.ino
1 /* @file HelloKeypad.pde
2 || @version 1.0
3 || @author Alexander Brevig
4 || @contact alexanderbrevig@gmail.com
5 ||
6 || @description
7 || | Demonstrates the simplest use of the matrix Keypad library.
8 || #
9
10  Pins are 8 -> 2
11 Links: 
12 -  http://www.addicore.com/v/vspfiles/downloadables/Product%20Downloadables/Project_Interface_Kit/Addicore_12-Key_Keypad_Tutorial.pdf
13 - https://learn.adafruit.com/biometric-security-box
14 */
15 #include <Keypad.h>
16
17 const byte ROWS = 4; //four rows
18 const byte COLS = 3; //three columns
19 char keys[ROWS][COLS] = {
20   {'1','2','3'},
21   {'4','5','6'},
22   {'7','8','9'},
23   {'*','0','#'}
24 };
25 byte rowPins[ROWS] = {8,7,6,5}; //connect to the row pinouts of the keypad
26 byte colPins[COLS] = {4,3,2}; //connect to the column pinouts of the keypad
27
28 // Try this if you think you have reversed the pins
29 //byte rowPins[ROWS] = {2, 3, 4, 5};
30 //byte colPins[COLS] = {6, 7, 8}; 
31
32 Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
33
34 void setup(){
35   Serial.begin(9600);
36 }
37   
38 void loop(){
39   char key = keypad.getKey();
40   
41   if (key){
42     Serial.println(key);
43   }
44 }