Arduino Based Electronic Voting Machine

We all are quite familiar with voting machines, even we have covered few other electronic voting machine projects previously here and here using RFID and AVR microcontroller. In this project, we have used the arduino controller to create an electronic voting machine.

 

Components

  1. Arduino Uno
  2. 16x2 LCD
  3. Push button
  4. Bread board
  5. Power
  6. Connecting wires

 

Circuit Diagram and Working  Explanation

In this project we have used four push buttons for four different candidates. We can increase the number of candidate but for better understanding we have limited it to four. When any voter press any of four button then respecting voting value will increment by one each time. After whole voting we will press result button to see the results. As the "result" button is pressed, arduino calculates the total votes of each candidate and show it on LCD display.

Arduino Based Electronic Voting Machine

Circuit of this project is quite easy which contains Arduino, push buttons and LCD. Arduino controls the complete processes like reading button, incrementing vote value, generating result and sending vote and result to LCD. Here we have added five buttons in which first button is for BJP, second for INC, third is for AAP, forth is for OTH means others and last button is used for calculating or displaying results.

Arduino Based Electronic Voting Machine Circuit Diagram

 

The five push buttons are directly connected with pin 15-19(A1-A5) of Arduino with respect to ground. A 16x2 LCD is connected with arduino in 4-bit mode. Control pin RS, RW and En are directly connected to arduino pin 12, GND and 11. And data pin D4-D7 is connected to pins 5, 4, 3 and 2 of arduino.

 

Program Description

First of all we include header and define pins for LCD and than initialize some variables and pin for taking candidate's voting input means switch.

Define

After it, initialize the LCD and give direction to input-output pins.

Initialize

and then make pullup the input pin by software.

Pull up

 In code we have used digital read function to read Button pressed.

reading

And then displaying voting on the LCD with the candidate party’s Name.

Displaying

Code: 

#include<LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

#define sw1 15
#define sw2 16
#define sw3 17
#define sw4 18
#define sw5 19
int vote1=0;
int vote2=0;
int vote3=0;
int vote4=0;
void setup()
{
  pinMode(sw1, INPUT);
  pinMode(sw2,INPUT);
  pinMode(sw3,INPUT);
  pinMode(sw4,INPUT);
  pinMode(sw5,INPUT);
  lcd.begin(16, 2);
  lcd.print("Voting Machine");
  lcd.setCursor(0,1);
  lcd.print("Circuit Digest");
  delay(3000);
  digitalWrite(sw1, HIGH);
  digitalWrite(sw2, HIGH);
  digitalWrite(sw3, HIGH);
  digitalWrite(sw4, HIGH);
  digitalWrite(sw5, HIGH);
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("BJP");
  lcd.setCursor(4,0);
  lcd.print("INC");
  lcd.setCursor(8,0);
  lcd.print("AAP");
  lcd.setCursor(12,0);
  lcd.print("OTH");
}
void loop()
{
  lcd.setCursor(0,0);
  lcd.print("BJP");
  lcd.setCursor(1,1);
  lcd.print(vote1);
  lcd.setCursor(4,0);
  lcd.print("INC");
  lcd.setCursor(5,1);
  lcd.print(vote2);
  lcd.setCursor(8,0);
  lcd.print("AAP");
   lcd.setCursor(9,1);
  lcd.print(vote3);
  lcd.setCursor(12,0);
  lcd.print("OTH"); 
  lcd.setCursor(13,1);
  lcd.print(vote4);
  if(digitalRead(sw1)==0)
    vote1++;
    while(digitalRead(sw1)==0);
  if(digitalRead(sw2)==0)
    vote2++;
    while(digitalRead(sw2)==0);
  if(digitalRead(sw3)==0)
    vote3++;
    while(digitalRead(sw3)==0);
   if(digitalRead(sw4)==0)
    vote4++;
    while(digitalRead(sw4)==0);
   if(digitalRead(sw5)==0)
   {
     int vote=vote1+vote2+vote3+vote4;
     if(vote)
     {
      if((vote1 > vote2 && vote1 > vote3 && vote1 > vote4))
      {
       lcd.clear();
       lcd.print("BJP Wins");
       delay(2000);
       lcd.clear();
      }
      else if((vote2 > vote1 && vote2 > vote3 && vote2 > vote4))
      {
       lcd.clear();
       lcd.print("INC Wins");
       delay(2000);
       lcd.clear();
      }
      else if((vote3 > vote1 && vote3 > vote2 && vote3 > vote4))
      {
       lcd.clear();
       lcd.print("AAP Wins");
       delay(2000);
       lcd.clear();
      }
     else if(vote4 > vote1 && vote4 > vote2 && vote4 > vote3)
     {
       lcd.setCursor(0,0);
       lcd.clear();
       lcd.print("OTH Wins");
       delay(2000);
       lcd.clear();
     }
     
      else if(vote4 > vote1 && vote4 > vote2 && vote4 > vote3)
     {
       lcd.setCursor(0,0);
       lcd.clear();
       lcd.print("OTH Wins");
       delay(2000);
       lcd.clear();
     }
     
     else
     {
       lcd.clear();
       lcd.print("   Tie Up Or   ");
       lcd.setCursor(0,1);
       lcd.print("   No Result   ");
       delay(1000);
       lcd.clear();
     }
     
    }      
     else 
     {
       lcd.clear();
       lcd.print("No Voting....");
       delay(1000);
       lcd.clear();
     }
     vote1=0;vote2=0;vote3=0;vote4=0,vote=0;
     lcd.clear();
   }
   
}
  

Video: 

Comments (13)

  • Alfred's picture
    Alfred

    Can you help me in addition with the recognition of finger print? If the same finger print is discovered and i will display error?

    Jan 25, 2016
  • Gaurav 's picture
    Gaurav

    Will u please help me out that
    Which software is being used to write program in arduino uno?????

    Feb 24, 2016
  • Prosenjeet Sengupta's picture
    Prosenjeet Sengupta

    It doesn't store the result so if power suppyly is lost the memory erases.... You can use eeprom of the arduino using eeprom.h library to store the result

    Jul 27, 2016
  • Maddy's picture
    Maddy

    Good suggestion Prosenjeet !

    Aug 20, 2016
  • HARSH's picture
    HARSH

    HOW TO MAKE AN EVM

    Aug 25, 2016
  • SHIVAM's picture
    SHIVAM

    Where does pin 2 and 16 of LCD are connected.

    Oct 20, 2016
  • Maddy's picture
    Maddy

    It is the symbol of Power supply positive terminal or Vcc.

    Oct 28, 2016
  • manushiya's picture
    manushiya

    how to avoid the pressing the switch more than one times by a person

    Mar 19, 2017
  • Abhishek's picture
    Abhishek

    Either we can delay in between two continuous button pressing or for more accurate solution we can use finger print sensor.

    Jul 05, 2017
  • Sidhartha Raghaw 's picture
    Sidhartha Raghaw

    How much power supply does.it.need to work

    May 11, 2017
  • Hira's picture
    Hira

    Hi !can u help me?
    When I am doing coding in ardino it showing code error .can u tell me why ?

    Jul 01, 2017

Leave a comment