Arduino Voting Machine

Add Your Project

This Project will teach you to build a simple Arduino based Voting machine using simple components such as push buttons and LCD. The highlighting feature of this system is that Serial Monitor in Arduino IDE is used to perform the polling operation no other external applications needed.

Key Features:

-Every step of polling operation will be under control of the supervisor.
-Password enabled security system.
-Poll results can be obtained instantly.
-Voter will be aware of the candidate he is voting for.

Components Required :

-Arduino Uno – qty 1
-16×2 LCD -qty 1
-Push Buttons – As required
-Potentiometer 100k – qty1
-Breadboard -qty 1
-Connecting Wires – As required.

Connection:

The design of the voting machine was given here. The Arduino reads the keypad input by the process of Polling. A 16×2 LCD was connected to the PORTD in 4 bit mode. This system will be operated by plugging the Arduino to the your PC and controlling using Serial monitor of Arduino IDE.

You can increase the number of buttons you use based on the number of candidates for the poll. Afix the LCD along with the potentiometer to the board and finish up all the connections as shown in the schematic design.

Code:

#include <LiquidCrystal.h>
int votes[4]={0,0,0,0};
char inbyte;
LiquidCrystal lcd(7, 6, 5, 4, 3, 2); //LCD connections
String pwd=”VOTE”; //Default Password
String inpt=””;
boolean flag=false;
boolean securitygranted=false;
int i;

void setup() {
pinMode(A2, INPUT_PULLUP); //Setting pins as input
pinMode(A3, INPUT_PULLUP);
pinMode(A4, INPUT_PULLUP);
pinMode(A5, INPUT_PULLUP);
lcd.begin(16, 2);
lcd.display();
Serial.begin(9600); //Begin serial communication
Serial.println(“ENTER PASSWORD”);
}

void loop() {
while(flag==true) //Check flag for “V” command
{
if(digitalRead(A2) == LOW)
{
flag=false;
lcd.print(“MARK”); //Example candidate name
votes[0]=votes[0]+1;
}
else if(digitalRead(A3) == LOW)
{
flag=false;
lcd.print(“JILL”);
votes[1]=votes[1]+1;
}
else if(digitalRead(A4) == LOW)
{
flag=false;
lcd.print(“JACK”);
votes[2]=votes[2]+1;
}
else if(digitalRead(A5) == LOW)
{
flag=false;
lcd.print(“TOMY”);
votes[3]=votes[3]+1;
}
}
}

void serialEvent()
{
while(Serial.available())
{
inbyte=(char)Serial.read(); //Reading incoming character
if(securitygranted==false)
{
inpt += inbyte;
inbyte=’\n’;
}
}
commandcheck();
}

void commandcheck()
{
switch (securitygranted) //See for the security permissions
{
case false: {
if(inpt==pwd) //Checking for password match
{
securitygranted=true;
inbyte=’\n’;
inpt=””;
Serial.println(“ACCESS GRANTED”);
}
else if((inpt!=pwd)&&(inpt.length()>3)) //Mismatch
{
Serial.println(inpt);
inpt=””;
inbyte=’\n’;
Serial.println(“WRONG PASSWORD”);
Serial.println(“ENTER PASSWORD”);
Serial.end();
delay(100);
Serial.begin(9600);
}
break;
}

case true: {
if(inbyte==’V’)
{
flag=true; //Allowing voter to cast a single vote
Serial.println(“OK”);
lcd.clear();
inbyte=’\n’;
}
else if(inbyte==’D’)
{
for(i=0;i<=3;i++) //Displaying vote tally
Serial.println(votes[i]);
inbyte=’\n’;
}
else
{Serial.println(“UNKNOWN COMMAND”);}
break;
}
}
}

Now you are ready to go and operate your voting machine. Connect your Arduino to the PC using the USB. Now open the Serial monitor to conduct the poll. Enter the password to get access to the system.

** Source : https://www.instructables.com/id/Arduino-Voting-machine/

Comments

( 0 Comments )

    Notice: Trying to get property of non-object in /home/ielectro/public_html/wp-includes/comment-template.php on line 551

Leave a Reply

Your email address will not be published. Required fields are marked *