Code and circuit for EVM

 

Code:

#include <Wire.h>

#include <LiquidCrystal_I2C.h>


LiquidCrystal_I2C lcd(0x27,20,4);

#define SW1 2

#define SW2 3

#define SW3 4

#define SW4 5

#define SW5 6

#define BUZ 7

int vot1=0;

int vot2=0;

int vot3=0;

int vot4=0;

// pin defins

void setup()

{

  /*

 code started

*/

pinMode(SW1, INPUT);

pinMode(SW2,INPUT);

pinMode(SW3,INPUT);

pinMode(SW4,INPUT);

pinMode(SW5,INPUT);

pinMode(BUZ,OUTPUT);


 lcd.init();

  lcd.init();

  lcd.backlight();

lcd.print(" Electronic ");

lcd.setCursor(0,1);

lcd.print(" Voting Machine ");

delay(4000);

digitalWrite(SW1, HIGH);

digitalWrite(SW2, HIGH);

digitalWrite(SW3, HIGH);

digitalWrite(SW4, HIGH);

digitalWrite(SW5, HIGH);

lcd.clear();

lcd.setCursor(1,0);

lcd.print("BJP");

lcd.setCursor(5,0);

lcd.print("CON");

lcd.setCursor(9,0);

lcd.print("AAP");

lcd.setCursor(13,0);

lcd.print("TMC");

}

void loop()

{

lcd.setCursor(1,0);

lcd.print("BJP");

lcd.setCursor(1,1);

lcd.print(vot1);

lcd.setCursor(5,0);

lcd.print("CON");

lcd.setCursor(5,1);

lcd.print(vot2);

lcd.setCursor(9,0);

lcd.print("AAP");

lcd.setCursor(9,1);

lcd.print(vot3);

lcd.setCursor(13,0);

lcd.print("TMC");

lcd.setCursor(13,1);

lcd.print(vot4);

if(digitalRead(SW1)==0)

vot1++;

while(digitalRead(SW1)==0);

if(digitalRead(SW2)==0)

vot2++;

while(digitalRead(SW2)==0);

if(digitalRead(SW3)==0)

vot3++;

while(digitalRead(SW3)==0);

if(digitalRead(SW4)==0)

vot4++;

while(digitalRead(SW4)==0);

if(digitalRead(SW5)==0)

{

int vot=vot1+vot2+vot3+vot4;

if(vot)

{

if((vot1 > vot2 && vot1 > vot3 && vot1 > vot4))

{

lcd.clear();

lcd.print("BJP is Winner");

delay(3000);

lcd.clear();

}

else if((vot2 > vot1 && vot2 > vot3 && vot2 > vot4))

{

lcd.clear();

lcd.print("CON is Winner");

delay(3000);

lcd.clear();

}

else if((vot3 > vot1 && vot3 > vot2 && vot3 > vot4))

{

lcd.clear();

lcd.print("AAP is Winner");

delay(3000);

lcd.clear();

}

else if(vot4 > vot1 && vot4 > vot2 && vot4 > vot3)

{

lcd.setCursor(0,0);

lcd.clear();

lcd.print("N is Winner");

delay(3000);

lcd.clear();

}


else if(vot4 > vot1 && vot4 > vot2 && vot4 > vot3)

{

lcd.setCursor(0,0);

lcd.clear();

lcd.print("TMC is Winner");

delay(3000);

lcd.clear();

}

else

{

lcd.clear();

lcd.print(" Tie Up Or ");

lcd.setCursor(0,1);

lcd.print(" No Result ");

delay(3000);

lcd.clear();

digitalWrite(BUZ, HIGH);

delay(500);

digitalWrite(BUZ, LOW);

}


}

else

{

lcd.clear();

lcd.print("No Voting....");

delay(3000);

lcd.clear();

digitalWrite(BUZ, HIGH);

delay(500);

digitalWrite(BUZ, LOW);

}

vot1=0;vot2=0;vot3=0;vot4=0,vot=0;

lcd.clear();

}


}

Post a Comment

0 Comments