A electronic voting machine is a best way to cast your vote and declaring result by reducing time effectively in very short time in recent time electronic voting machine has almost replaced convetional voting machine.before moving through it is assumed you know LCD interfacing.Code for project is written in C and circuit uses AT89c51 micro-controller operated at 12mhz crystal frequency
Proteus Design
switch 1 is connected to pin P0.0 allow admin to control the voting process manually such that no one can cast vote more than one time in his alloted time. four switches connected to port P0.1-P0.4 corresponding to party "BJP","COG","AAP" and "JDU". every time a switch or a button is pressed it counts vote for candidate of your choice. switch at P0.5 will be pressed at end to declare result. To understand LCD connection first read the article LCD-interfacing.
CODE
when the sw1(p0.0) is pressed it allow voters to choose candidate by making them eligible to press sw2-sw4(p0.1-p0.4) i.e put their vote in a define order then the function count(); increase the vote for corresponding candidate by one
every time switch has been pressed function display_vote(); save the result in a variable that you can display on lcd at the end by making sw5(p0.5) high.
code above decides the party in majority by comparing their votes and display which party wins in the election.if two or more party having same vote it tells us the tie among them.
complete code
#include<reg51.h>
#define lcdport P2
sbit rs=P3^0;
sbit rw=P3^1;
sbit en=P3^2;
sbit start= P1^0;
sbit stop= P1^5;
sbit party1=P1^1; //Candidate1
sbit party2=P1^2; //Candidate2
sbit party3=P1^3; //Candidate3
sbit party4=P1^4; //Candidate4
void lcdcmd(char);
void lcdint();
void lcddata(char);
void lcdstring(char *);
void delay(unsigned int);
void longdelay(unsigned int);
void dispaly_vote(unsigned int) ;
void count();
void result();
void check();
unsigned int vote1,vote2,vote3,vote4 ;
char vote_no[4];
void main()
{
lcdport=0x00;
party1 =party2 = party3 = party4 = 0;
vote1 = vote2 = vote3 = vote4 =0;
start=stop=0;
lcdint();
lcdstring("press start ");
lcdcmd(0xc0);
lcdstring("to initiate");
while(1)
{
if(start==1)
{
lcdcmd(0x84);
lcdcmd(0x01);
lcdstring("WELCOME!!");
longdelay(200);
lcdcmd(0x01);
lcdstring("press any key");
lcdcmd(0xc0);
lcdstring("to vote");
longdelay(200);
lcdcmd(0x01);
lcdstring("BJP");
delay(500);
lcdcmd(0x84);
lcdstring("CNG");
delay(500);
lcdcmd(0x88);
lcdstring("AAP");
delay(500);
lcdcmd(0x8C);
lcdstring("JDU");
count();
lcdcmd(0x01);
lcdcmd(0x80);
lcdstring("thank you!!");
longdelay(500);
check();
}
}
}
void check()
{
if(party1==0&&party2==0&&party3==0&&party4==0)
{
if(stop!=0)
{
while(1)
{
result();
}
}
}
}
void result()
{
int max=0,flag=0;
lcdcmd(0x01);
lcdstring("BJP");
delay(500);
lcdcmd(0x84);
lcdstring("CNG");
delay(500);
lcdcmd(0x88);
lcdstring("AAP");
delay(500);
lcdcmd(0x8C);
lcdstring("JDU");
lcdcmd(0xc0);
dispaly_vote(vote1);
lcdcmd(0xc4);
dispaly_vote(vote2);
lcdcmd(0xc8);
dispaly_vote(vote3);
lcdcmd(0xcc);
dispaly_vote(vote4);
if(vote1>max)
{
max=vote1;
}
if(vote2>max)
{
max=vote2;
}
if(vote3>max)
{
max=vote3;
}
if(vote4>max)
{
max=vote4;
}
longdelay(500);
if ( (vote1 == max) && ( vote2 != max) && (vote3 != max)&& (vote4 != max) )
{
flag = 1;
lcdcmd(0x01);
lcdcmd(0x80);
lcdstring("BJP");
lcdcmd(0xc5);
lcdstring("wins");
longdelay(500);
}
if ( (vote2 == max) && ( vote1 != max) && (vote3 != max)&& (vote4 != max) )
{
flag = 1;
lcdcmd(0x01);
lcdcmd(0x80);
lcdstring("CONG");
lcdcmd(0xc5);
lcdstring("wins");
longdelay(500);
}
if ( (vote3 == max) && ( vote2 != max) && (vote1 != max)&& (vote4 != max) )
{
flag = 1;
lcdcmd(0x01);
lcdcmd(0x80);
lcdstring("AAP");
lcdcmd(0xc5);
lcdstring("wins");
longdelay(500);
}
if ( (vote4 == max) && ( vote2 != max) && (vote1 != max)&& (vote3!= max) )
{
flag = 1;
lcdcmd(0x01);
lcdcmd(0x80);
lcdstring("JDU");
lcdcmd(0xc5);
lcdstring("wins");
longdelay(500);
}
if(flag==0)
{
lcdcmd(0x01);
lcdcmd(0x80);
lcdstring("clash between");
lcdcmd(0xc0);
if(vote1==max)
{
lcdstring("BJP");
}
if(vote2==max)
{
lcdstring("CONG");
}
if(vote3==max)
{
lcdstring("AAP");
}
if(vote4==max)
{
lcdstring("JDU");
}
longdelay(200);
}
}
void dispaly_vote(unsigned int vote) // send 0-9 character values
{
int k,p;
for (k=0;k<=2;k++)
{
vote_no[k]=vote%10;
vote=vote/10;
}
for (p=2;p>=0;p--)
{
lcddata(vote_no[p]+48);
}
}
void count() // count votes
{
while(party1==0&&party2==0&&party3==0&&party4==0);
if (party1==1)
{
vote1 = vote1 + 1;
}
if (party2==1)
{
vote2 = vote2 + 1;
}
if (party3==1)
{
vote3 = vote3 + 1;
}
if (party4==1)
{
vote4 = vote4 + 1;
}
}
void delay(unsigned int x)
{
unsigned int i;
for(i=0;i<x;i++);
}
void longdelay(unsigned int u)
{
unsigned int i,j;
for(i=0;i<u;i++)
for(j=0;j<1275;j++);
}
void lcdint()
{
lcdcmd(0x38);
delay(500);
lcdcmd(0x01);
delay(500);
lcdcmd(0x0c);
delay(500);
lcdcmd(0x80);
delay(500);
lcdcmd(0x0e);
delay(500);
}
void lcdcmd(char value)
{
lcdport = value;
rw=0;
rs=0;
en=1;
delay(500);
en=0;
}
void lcdstring(char *p)
{
while(*p!='\0')
{
lcddata(*p);
delay(2000);
p++;
}
}
void lcddata(char value)
{
lcdport = value;
rs=1;
rw=0;
en=1;
delay(500);
en=0;
}
VIDEO
Category:
Comments
proteus help
yes,you can compile same code
yes,you can compile same code to generate hex file in KEIL
hiii i m diplome student
hiiii i m diploma student i need ur help
<p>I want to know the component which is used in evm using 8051 and price of the each component n total price of project sooo plzzz help its urgent beacuse i want start my project n give presentation on it plzzzz reply </p>