-
Notifications
You must be signed in to change notification settings - Fork 1
/
Keypad_04.ino
72 lines (63 loc) · 1.69 KB
/
Keypad_04.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* @file CustomKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact alexanderbrevig@gmail.com
||
|| @description
|| | Demonstrates changing the keypad size and key values.
|| #
*/
/* The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3) */
#include <Keypad.h>
#include <LiquidCrystal.h>
#include <EEPROM.h>
char key,keyP = NO_KEY;
int i = 0;
int c = 0;
const int rs = 8, en = 9, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'D','#','0','*'},
{'C','9','8','7'},
{'B','6','5','4'},
{'A','3','2','1'}
};
byte rowPins[ROWS] = {36, 34, 32, 30}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {44, 42, 40, 38}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
void setup(){
lcd.begin(16,2);
lcd.clear();
}
void loop(){
if(i==16){
lcd.setCursor(0,1);}
if(i==32){
lcd.setCursor(0,0);
i=0;}
lcd.blink();
c=0;
key=customKeypad.getKey();
if(key!=NO_KEY){c++;}
while(key!='*' || key!=NO_KEY){
key=customKeypad.getKey();
if(key=='*'){escriba(keyP,c);}
if(key==keyP){c++;}
}
}
void escriba(char key, int c){
}