-
Notifications
You must be signed in to change notification settings - Fork 0
/
yes_no_menu.ino
106 lines (79 loc) · 1.78 KB
/
yes_no_menu.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//Created By : Ali Abedi Madiseh///
////////aam.7596@gmail.com/////////
//////////Jan ..... 2023///////////:)
//My Key Values:
//Yes = 42
//No = 64
//Normal = 1023
//check input values :
// value = analogRead(A0); /connect 2 push button to pin A0
# include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd (0x27 , 16, 2);
int buttonst = -1;
int btn = A0;
int buttonvalue;
int yescount;
int nocount;
void setup() {
lcd.init();
lcd.clear();
lcd.backlight();
lcd.setCursor(1,0);
lcd.print("item1");
lcd.setCursor(9,0);
lcd.print("item2");
lcd.setCursor(1,1);
lcd.print("item3");
lcd.setCursor(9,1);
lcd.print("item4");
}
void loop() {
start();
buttonvalue = analogRead(btn);
//yes button
if(buttonvalue == 42){
//debounce
delay(1000);
}
//no button
else if(buttonvalue == 64){
//debounce
buttonst ++ ;
delay(1000);
if (buttonst == 0){
lcd.setCursor(0,0);
lcd.print(" ");
lcd.setCursor(8,0);
lcd.print(">");
}
else if (buttonst == 1){
lcd.setCursor(8,0);
lcd.print(" ");
lcd.setCursor(0,1);
lcd.print(">");
}
else if (buttonst == 2){
lcd.setCursor(0,1);
lcd.print(" ");
lcd.setCursor(8,1);
lcd.print(">");
}
else if (buttonst == 3){
buttonst = -1 ;
}
}
}
void start(){
if(buttonst == -1){
lcd.setCursor(8,1);
lcd.print(" ");
lcd.setCursor(0,0);
lcd.print(">item1");
lcd.setCursor(9,0);
lcd.print("item2");
lcd.setCursor(1,1);
lcd.print("item3");
lcd.setCursor(9,1);
lcd.print("item4");
}
}