Here in this project, we will make a smart electronic voting machine using an LCD and 8051 microcontrollers. The purpose behind ​​this project is to build an electronic voting machine that will help to avoid the manipulation of the manual voting system which is during elections voting. This Smart Electronic Voting machine system is simple portable, cheap, and very effective to use anywhere, where voting is required.

Table of Content

  • Smart Electronic Voting Machine
  • Video Demonstration of the project
  • Components Required
  • Proteus simulation Schematic Diagram
  • Circuit Diagram
  • Working of the Project
  • Code of the Project:
  • Final Note

Smart LCD-Based Electronic Voting Machine

Electronic Voting Machine is the need of today’s era. An electronic voting machine is the first need of any healthy democracy.  LCD Based Electronic Voting Machine or EVM is a simple electronic device used to record votes in place of ballot papers and boxes which were used earlier in the traditional voting system. The fundamental right to vote or simply voting in elections forms the basis of democracy. In all earlier elections be it state elections or centre elections a voter used to cast their favourite candidate by putting the stamp against their name and then folding the ballot paper as per a prescribed method before putting it in the Ballot Box. This is a very hectic and long, time-consuming process and very much prone to errors. This situation continued till the election scene was completely changed by the electronic voting machines. No more ballot paper, ballot boxes, stamping, etc. all this condensed into a simple box called the ballot unit of the electronic voting machine. For further future advancement, you can use fingerprint or biometric identifiers. Biometric identifiers cannot be easily misplaced, forged, or shared, they are considered more reliable for person recognition than traditional token or knowledge-based methods. So, the electronic voting system has to be improved based on the current technologies viz., the biometric system. Here in the project, we are not using the fingerprint-based voting machine but we can include that in future.

Video Demonstration of the project:

Components Required: 

  • 8051 Microcontroller
  • 16×2 LCD Display
  • Diode
  • Capacitors
  • Resistor
  • 7805 Voltage Regulator
  • Transformer (12-0-12)
  • Led (3mm)
  • Crystal oscillators 11.0592Mhz
  • PCB (Printed Circuit Board)
  • Push Buttons/micro switches
  • Ribbon Wires

Sources to buy Components:

8051 Programmer: buy from here & here

AT89S52: buy from here

16*2 LCD: buy from here & here

12-0-12 Trans 2 Amp: buy from here

Proteus simulation Schematic Diagram:

Circuit Diagram:

Microcontroller Section
Power supply section
Reset and Oscillator Circuit
Complete Circuit Diagram

Working of the Project:

8051 microcontroller is the heart and brain of this Project. 8051 microcontroller controls the complete all the processes happening in the project like reading button, incrementing vote value, generating a result, and sending vote and result in LCD Display. Input is given through the microswitches and output is taken on the LCD.

We have added 6 microswitches to the project. Four switches for the candidates and the remaining 2 switches for the start and result operations. The start button will initialise the process and the result button will display the result on the LCD display. Watch the full video to see the complete work of the project.

Code of the Project:

// LCD based voting machine using 8051 microcontroller 
// circuitsbazaar.com
#include<reg51.h>
#define msec 50
#define lcd_data_str_pin P0 
sbit rs = P2^7;  //Register select pin for 16*2 LCD
sbit rw = P2^6;  //Read write pin for 16*2 LCD
sbit en = P2^5;  //Enable(EN) pin for 16*2 LCD
sbit ini_pin = P1^0; // Start voting pin for microswitch
sbit stop_pin = P1^5; // Stop voting pin for microswitch
sbit candidate_1=P1^1;  // First Candidate  
sbit candidate_2=P1^2;  // Second Candidate
sbit candidate_3=P1^3;  // third Candidate
sbit candidate_4=P1^4;  //fourth Candidate
int max = 0;   // variable 
int carry = 0;  // variable 
int arr[4]; // array for the storage 

int vote_amt[3],j;
unsigned int vote_1,vote_2,vote_3,vote_4;

void delay(int delay_time)  // delay function to provide time gap
{
int j,k;
for(j=0;j<=delay_time;j++)
  for(k=0;k<=1000;k++);
}

void lcd_cmd(unsigned char cmd_addr)  //Through this function we will send some set commands to the LCD
{
lcd_data_str_pin = cmd_addr;
en = 1;
rs = 0;
rw = 0;
delay(1);
en = 0;
return;
}

void lcd_data_str(char str[50])  //string function to send data to the lcd
{ 
int p;
for (p=0;str[p]!='\0';p++)
{
  lcd_data_str_pin = str[p];
  rw = 0;
  rs = 1;
  en = 1;
  delay(1);
  en = 0;
}
return;
}

void lcd_data_int(unsigned int vote)  //this is for to send 0-9 character values
{ 
char dig_ctrl_var;
int p;
for (j=2;j>=0;j--)
{
  vote_amt[j]=vote%10;
  vote=vote/10;
}

for (p=0;p<=2;p++)
{
  dig_ctrl_var = vote_amt[p]+48;
  lcd_data_str_pin = dig_ctrl_var;
  rw = 0;
  rs = 1;
  en = 1;
  delay(1);
  en = 0;
}
return;
} 

void vote_count()  // this Function is to count votes
{
while (candidate_1==0 && candidate_2==0 && candidate_3==0 && candidate_4==0);
if (candidate_1==1)
{
  while (candidate_1 == 1);
   {
    vote_1 = vote_1 + 1;
   }
}

if (candidate_2==1)
{
  while (candidate_2 == 1);
   {
    vote_2 = vote_2 + 1;
   }
}

if (candidate_3==1)
{
  while (candidate_3 == 1);
   {
    vote_3 = vote_3 + 1;
   }
}

if (candidate_4==1)
{
  while (candidate_4 == 1);
   {
    vote_4 = vote_4 + 1;
   }
}
}

void lcd_ini()
{
    lcd_cmd(0x38);
delay(msec);
lcd_cmd(0x0E);
delay(msec);
lcd_cmd(0x01);
delay(msec);
lcd_cmd(0x81);
delay(msec);
lcd_data_str("Welcome!!!");
delay(100);
lcd_cmd(0x01);
delay(msec);
lcd_cmd(0x80);
delay(msec);
lcd_data_str( "Press" );
delay(msec);
lcd_cmd(0x14);
delay(msec);
lcd_data_str("button");
delay(msec);

delay(msec);
lcd_cmd(0xC0);
delay(msec);
lcd_data_str("to");
delay(msec);
lcd_cmd(0x14);
delay(msec);
lcd_data_str("vote");
delay(100);
lcd_cmd(0x01);
delay(msec);
lcd_cmd(0x80);
delay(msec);
lcd_data_str("P1");
delay(msec);
lcd_cmd(0x84);
delay(msec);
lcd_data_str("P2");
delay(msec);
lcd_cmd(0x88);
delay(msec);
lcd_data_str("P3");
delay(msec);
lcd_cmd(0x8C);
delay(msec);
lcd_data_str("P4");
delay(msec);

vote_count();
lcd_cmd(0x01);
delay(msec);
lcd_cmd(0x85);
delay(msec);
lcd_data_str("Thank");
delay(msec);
lcd_cmd(0x14);
delay(msec);
lcd_data_str("You!!");
delay(100);
}

void results()  // This Function is to show results
{
int i;
carry = 0;
lcd_cmd(0x01);
delay(msec);
lcd_cmd(0x80);
delay(msec);
lcd_data_str("Results");
delay(msec);
lcd_cmd(0x14);
delay(msec);
lcd_data_str("Are");
delay(msec);
lcd_cmd(0x14);
delay(msec);
lcd_data_str("Out");
delay(msec);

  lcd_cmd(0x01);
delay(msec);
lcd_cmd(0x80);
delay(msec);
lcd_data_str("P1");
delay(msec);
lcd_cmd(0x84);
delay(msec);
lcd_data_str("P2");
delay(msec);
lcd_cmd(0x88);
delay(msec);
lcd_data_str("P3");
delay(msec);
lcd_cmd(0x8C);
delay(msec);
lcd_data_str("P4");
delay(msec);

lcd_cmd(0xC0);
delay(100);
lcd_data_int(vote_1);
delay(msec);

lcd_cmd(0xC4);
delay(msec);
lcd_data_int(vote_2);
delay(msec);

lcd_cmd(0xC8);
delay(msec);
lcd_data_int(vote_3);
delay(msec);

lcd_cmd(0xCC);
delay(msec);
lcd_data_int(vote_4);
delay(300);

arr[0] = vote_1;
arr[1] = vote_2;
arr[2] = vote_3;
arr[3] = vote_4;

for( i=0; i<4; i++)
{
  if(arr[i]>=max)
  max = arr[i];
}

if ( (vote_1 == max) && ( vote_2 != max) && (vote_3 != max)&& (vote_4 != max) )
{
  carry = 1;
  lcd_cmd(0x01);
  delay(msec);
  lcd_cmd(0x82);
  delay(msec);
  lcd_data_str("Hurray!!!");
  delay(50);
  lcd_cmd(0xC4);
  delay(msec);
  lcd_data_str("P1");
  delay(msec);
  lcd_cmd(0x14);
  delay(msec);
  lcd_data_str("wins");
  delay(msec);
}

if ( (vote_2 == max) && ( vote_1 != max) && (vote_3 != max)&& (vote_4 != max) )
{
  carry = 1;
  lcd_cmd(0x01);
  delay(msec);
  lcd_cmd(0x82);
  delay(msec);
  lcd_data_str("Hurray!!!");
  delay(50);
  lcd_cmd(0xC4);
  delay(msec);
  lcd_data_str("P2");
  delay(msec);
  lcd_cmd(0x14);
  delay(msec);
  lcd_data_str("wins");
  delay(msec);
}

if ( (vote_3 == max) && ( vote_2 != max) && (vote_1 != max)&& (vote_4 != max) )
{
  carry = 1;
  lcd_cmd(0x01);
  delay(msec);
  lcd_cmd(0x82);
  delay(msec);
  lcd_data_str("Hurray!!!");
  delay(50);
  lcd_cmd(0xC4);
  delay(msec);
  lcd_data_str("P3");
  delay(msec);
  lcd_cmd(0x14);
  delay(msec);
  lcd_data_str("wins");
  delay(msec);
}

if ( (vote_4 == max) && ( vote_2 != max) && (vote_3 != max)&& (vote_1 != max) )
{
  carry = 1;
  lcd_cmd(0x01);
  delay(msec);
  lcd_cmd(0x82);
  delay(msec);
  lcd_data_str("Hurray!!!");
  delay(50);
  lcd_cmd(0xC4);
  delay(msec);
  lcd_data_str("P4");
  delay(msec);
  lcd_cmd(0x14);
  delay(msec);
  lcd_data_str("wins");
  delay(msec);
}

if (carry==0)
{
  lcd_cmd(0x01);
  delay(msec);
  lcd_cmd(0x82);
  delay(msec);
  lcd_data_str("clash");
  delay(50);
  lcd_cmd(0x14);
  delay(msec);
  lcd_data_str("between!!!");
  delay(50);
  if(vote_2 == max)
  {
   lcd_cmd(0xC5);
   lcd_data_str("P2");
   delay(50);
  }
  if(vote_3 == max)
  {
   lcd_cmd(0xC9);
   lcd_data_str("P3");
   delay(50);
  }
  if(vote_4 == max)
  {
   lcd_cmd(0xCD);
   lcd_data_str("P4");
   delay(50);
  }
}
}

void main()
{
ini_pin = stop_pin = 1;
vote_1 = vote_2 = vote_3 = vote_4 = 0;
candidate_1 = candidate_2 = candidate_3 = candidate_4 = 0;
lcd_cmd(0x38);
delay(msec);
lcd_cmd(0x0E);
delay(msec);
lcd_cmd(0x01);
delay(msec);
lcd_cmd(0x80);
delay(msec);
lcd_data_str( "Press" );
delay(msec);
lcd_cmd(0x14);
delay(msec);
lcd_data_str("init");
delay(msec);

delay(msec);
lcd_cmd(0xC0);
delay(msec);
lcd_data_str("to");
delay(msec);
lcd_cmd(0x14);
delay(msec);
lcd_data_str("begin");
delay(100);
while(1)
{
  while(ini_pin != 0)
  {
   if (stop_pin == 0)
   break;
  }
  if (stop_pin == 0)
  {
  break;
  }
  lcd_ini();
}

while(1)
{
results();
}
}

 You can make any changes like Party/Candidate Name. you can choose your other ports as well in programming. Just experiment and complete your project.

To buy the kit or project you can call on +91-8684884488