-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKimat_OnewireKeypad_Moduleexample_with_LCD.ino
65 lines (56 loc) · 1.67 KB
/
Kimat_OnewireKeypad_Moduleexample_with_LCD.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
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <OnewireKeypad.h>
char KEYS[] = {
'1', '2', '3', 'A',
'4', '5', '6', 'B',
'7', '8', '9', 'C',
'*', '0', '#', 'D'
};
LiquidCrystal_I2C lcd(0x3F,16,2);
OnewireKeypad <Print, 16 > KP2(Serial, KEYS, 4, 4, A0, 4700, 1000, 10000, ExtremePrec );
void setup () {
Serial.begin(115200);
lcd.init();
lcd.backlight();
// This method is set in the constructor with a default value of 5.0
// You only need to include this method if your Arduino is not supplying 5v to
// the keypad. ie. ~4.7v or even with 3.3v Arduino boards too.
//KP2.SetKeypadVoltage(5.0);
KP2.SetKeypadVoltage(4.95);
lcd.setCursor(0,0);lcd.print(" LAYAD CIRCUITS ");
lcd.setCursor(0,1);lcd.print("LC 1-WIRE KEYPAD");
delay(2000);
lcd.clear();
}
void loop()
{
if ( char key = KP2.Getkey() ) {
switch (KP2.Key_State()) {
case PRESSED:
lcd.clear();
lcd.setCursor(0,0);lcd.print("LC 1-WIRE KEYPAD");
lcd.setCursor(2,1);lcd.print(key);
lcd.setCursor(4,1);lcd.print(": PRESSED");
Serial.print(key);
Serial.println(" PRESSED");
break;
case RELEASED:
lcd.clear();
lcd.setCursor(0,0);lcd.print("LC 1-WIRE KEYPAD");
lcd.setCursor(2,1);lcd.print(key);
lcd.setCursor(4,1);lcd.print(": RELEASED");
Serial.print(key);
Serial.println(" RELEASED");
break;
case HELD:
lcd.clear();
lcd.setCursor(0,0);lcd.print("LC 1-WIRE KEYPAD");
lcd.setCursor(2,1);lcd.print(key);
lcd.setCursor(4,1);lcd.print(": HOLDING");
Serial.print(key);
Serial.println(" HOLDING");
break;
}
}
}