0% found this document useful (0 votes)
13 views4 pages

Voting Machine - Ino

time pass

Uploaded by

fa011020211
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views4 pages

Voting Machine - Ino

time pass

Uploaded by

fa011020211
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

//Smart Electronic Voting Machine

#include <EEPROM.h>
#include <LiquidCrystal.h> //this library is included in the Arduino IDE

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

int keyswitch = A0;


int pushButton = A1;

int touch1 = A5;


int touch2 = A4;
int touch3 = A3;
int touch4 = A2;

int start, timer;

int P1_a, P1_b, P1_c, P1_d, P1_e;


int P2_a, P2_b, P2_c, P2_d, P2_e;
int P3_a, P3_b, P3_c, P3_d, P3_e;
int P4_a, P4_b, P4_c, P4_d, P4_e;

int buz = 13;


int led = 8;

void setup() {
pinMode(keyswitch, INPUT_PULLUP);
pinMode(pushButton, INPUT_PULLUP);

pinMode(touch1, INPUT);
pinMode(touch2, INPUT);
pinMode(touch3, INPUT);
pinMode(touch4, INPUT);

pinMode(buz, OUTPUT);
pinMode(led, OUTPUT);

eeprom_read();

lcd.begin(20,4);
lcd.clear();
lcd.setCursor(0,0);
lcd.print(" WELCOME To ");
lcd.setCursor(0,1);
lcd.print(" Smart Electronic ");
lcd.setCursor(0,2);
lcd.print(" Voting Machine ");
lcd.setCursor(0,3);
lcd.print("<<<<<<<<<<O>>>>>>>>>");
delay(2000);
lcd.clear();
}

void loop(){

if(digitalRead (pushButton) == 0){start=1;


digitalWrite(buz, HIGH);
delay(500);
digitalWrite(buz, LOW);
}

if(digitalRead (keyswitch) == 0){start=0;


digitalWrite(buz, HIGH);

if(timer>0){timer = timer-1;}
if(timer==1){
P1_a=0, P1_b=0, P1_c=0, P1_d=0, P1_e=0;
P2_a=0, P2_b=0, P2_c=0, P2_d=0, P2_e=0;
P3_a=0, P3_b=0, P3_c=0, P3_d=0, P3_e=0;
P4_a=0, P4_b=0, P4_c=0, P4_d=0, P4_e=0;
eeprom_write1();
eeprom_write2();
eeprom_write3();
eeprom_write4();
}
}else{digitalWrite(buz, LOW); timer=20;}

if (digitalRead (touch1) == 1 && start==1){start=0;


P1_a = P1_a+1;
if(P1_a>9){P1_a=0; P1_b = P1_b+1;}
if(P1_b>9){P1_b=0; P1_c = P1_c+1;}
if(P1_c>9){P1_c=0; P1_d = P1_d+1;}
if(P1_d>9){P1_d=0; P1_e = P1_e+1;}
eeprom_write1();
Alarm();
}

if (digitalRead (touch2) == 1 && start==1){start=0;


P2_a = P2_a+1;
if(P2_a>9){P2_a=0; P2_b = P2_b+1;}
if(P2_b>9){P2_b=0; P2_c = P2_c+1;}
if(P2_c>9){P2_c=0; P2_d = P2_d+1;}
if(P2_d>9){P2_d=0; P2_e = P2_e+1;}
eeprom_write2();
Alarm();
}

if (digitalRead (touch3) == 1 && start==1){start=0;


P3_a = P3_a+1;
if(P3_a>9){P3_a=0; P3_b = P3_b+1;}
if(P3_b>9){P3_b=0; P3_c = P3_c+1;}
if(P3_c>9){P3_c=0; P3_d = P3_d+1;}
if(P3_d>9){P3_d=0; P3_e = P3_e+1;}
eeprom_write3();
Alarm();
}

if (digitalRead (touch4) == 1 && start==1){start=0;


P4_a = P4_a+1;
if(P4_a>9){P4_a=0; P4_b = P4_b+1;}
if(P4_b>9){P4_b=0; P4_c = P4_c+1;}
if(P4_c>9){P4_c=0; P4_d = P4_d+1;}
if(P4_d>9){P4_d=0; P4_e = P4_e+1;}
eeprom_write4();
Alarm();
}
if(start==1){digitalWrite(led, HIGH);}
if(start==0){digitalWrite(led, LOW);}

lcd.setCursor(0,0);
lcd.print(" PTI = ");
lcd.print(P1_e);
lcd.print(P1_d);
lcd.print(P1_c);
lcd.print(P1_b);
lcd.print(P1_a);

lcd.setCursor(0,1);
lcd.print(" PML(N) = ");
lcd.print(P2_e);
lcd.print(P2_d);
lcd.print(P2_c);
lcd.print(P2_b);
lcd.print(P2_a);

lcd.setCursor(0,2);
lcd.print(" PPP = ");
lcd.print(P3_e);
lcd.print(P3_d);
lcd.print(P3_c);
lcd.print(P3_b);
lcd.print(P3_a);

lcd.setCursor(0,3);
lcd.print(" PML(Q) = ");
lcd.print(P4_e);
lcd.print(P4_d);
lcd.print(P4_c);
lcd.print(P4_b);
lcd.print(P4_a);

delay(50);
}

void Alarm(){
digitalWrite(buz, HIGH);
delay(200);
digitalWrite(buz, LOW);
delay(100);
digitalWrite(buz, HIGH);
delay(200);
digitalWrite(buz, LOW);
delay(100);
digitalWrite(buz, HIGH);
delay(200);
digitalWrite(buz, LOW);
}

void eeprom_write1(){
EEPROM.write(11, P1_a);
EEPROM.write(12, P1_b);
EEPROM.write(13, P1_c);
EEPROM.write(14, P1_d);
EEPROM.write(15, P1_e);
}

void eeprom_write2(){
EEPROM.write(21, P2_a);
EEPROM.write(22, P2_b);
EEPROM.write(23, P2_c);
EEPROM.write(24, P2_d);
EEPROM.write(25, P2_e);
}

void eeprom_write3(){
EEPROM.write(31, P3_a);
EEPROM.write(32, P3_b);
EEPROM.write(33, P3_c);
EEPROM.write(34, P3_d);
EEPROM.write(35, P3_e);
}

void eeprom_write4(){
EEPROM.write(41, P4_a);
EEPROM.write(42, P4_b);
EEPROM.write(43, P4_c);
EEPROM.write(44, P4_d);
EEPROM.write(45, P4_e);
}

void eeprom_read(){
P1_a = EEPROM.read(11);
P1_b = EEPROM.read(12);
P1_c = EEPROM.read(13);
P1_d = EEPROM.read(14);
P1_e = EEPROM.read(15);

P2_a = EEPROM.read(21);
P2_b = EEPROM.read(22);
P2_c = EEPROM.read(23);
P2_d = EEPROM.read(24);
P2_e = EEPROM.read(25);

P3_a = EEPROM.read(31);
P3_b = EEPROM.read(32);
P3_c = EEPROM.read(33);
P3_d = EEPROM.read(34);
P3_e = EEPROM.read(35);

P4_a = EEPROM.read(41);
P4_b = EEPROM.read(42);
P4_c = EEPROM.read(43);
P4_d = EEPROM.read(44);
P4_e = EEPROM.read(45);
}

You might also like