-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEVM.ino
106 lines (85 loc) · 1.73 KB
/
EVM.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
#include <LiquidCrystal.h>
LiquidCrystal lcd(13,12,5,4,3,2);
int grp[4],count;
byte back,add,next;
byte addState,backState,nextState,scrnState;
String names[4]={"Group A","Group B","Group C","Group D"};
void setup() {
// put your setup code here, to run once:
count=0;
for(byte a=0;a<4;a++)
{
grp[a]=0;
}
backState=nextState=addState=scrnState=false;
back=add=next=0;
lcd.begin(16,2);
lcd.print(" Electronic ");
lcd.setCursor(0,1);
lcd.print(" Voting Machine ");
pinMode(A3,INPUT);
pinMode(A4,INPUT);
pinMode(A5,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
back=digitalRead(A3);
add=digitalRead(A4);
next=digitalRead(A5);
if(add==HIGH&&addState==false)
{
addState=true;
}
if(back==HIGH&&backState==false)
{
backState=true;
}
if(next==HIGH&&nextState==false)
{
nextState=true;
}
if(add==LOW&&addState==true&&scrnState==false)
{
lcd.clear();
lcd.print(names[count]);
lcd.setCursor(0,1);
lcd.print(grp[count]);
scrnState=true;
addState=false;
}
if(add==LOW&&addState==true)
{
grp[count]++;
lcd.clear();
lcd.print(names[count]);
lcd.setCursor(0,1);
lcd.print(grp[count]);
addState=false;
}
if(back==LOW&&backState==true)
{
count--;
if(count<0)
{
count=3;
}
lcd.clear();
lcd.print(names[count]);
lcd.setCursor(0,1);
lcd.print(grp[count]);
backState=false;
}
if(next==LOW&&nextState==true)
{
count++;
if(count>3)
{
count=0;
}
lcd.clear();
lcd.print(names[count]);
lcd.setCursor(0,1);
lcd.print(grp[count]);
nextState=false;
}
}