Electronic Voting Machine using Arduino

Arduino

BySaddam 18

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

  • Alfred's picture
    Alfred
    Jan 25, 2016

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

  • Gaurav 's picture
    Gaurav
    Feb 24, 2016

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

  • Prosenjeet Sengupta's picture
    Prosenjeet Sengupta
    Jul 27, 2016

    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

  • HARSH's picture
    HARSH
    Aug 25, 2016

    HOW TO MAKE AN EVM

  • SHIVAM's picture
    SHIVAM
    Oct 20, 2016

    Where does pin 2 and 16 of LCD are connected.

  • Maddy's picture
    Maddy
    Oct 28, 2016

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

  • manushiya's picture
    manushiya
    Mar 19, 2017

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

  • Abhishek's picture
    Abhishek
    Jul 05, 2017

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

  • Sidhartha Raghaw 's picture
    Sidhartha Raghaw
    May 11, 2017

    How much power supply does.it.need to work

  • Hira's picture
    Hira
    Jul 01, 2017

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

  • yash jain 's picture
    yash jain
    Mar 10, 2018

    sir I am getting the error in the program as "stray '\302' in program" so what should I do and where are the 16 and 2 pin connected ?

  • Shaunak's picture
    Shaunak
    Apr 03, 2018

    I tried this but nothing is getting displayed on the lcd .

  • Aswinth Raj's picture
    Aswinth Raj
    Apr 06, 2018

    check you LCD connection and also the contrast level of the LCD

  • tamirat assefa's picture
    tamirat assefa
    May 23, 2018

    good work

  • Tanka's picture
    Tanka
    Jul 13, 2018

    How much votes can it save? I mean how many votes can be saved on arduino's internal eeprom. I am using Arduino Uno which has 1024 bytes of eeprom.

Log in or register to post Comment