Digital Voting Machine is one kind of microcontroller based device which can perform in election. Once I had made Digital Voting Machine when I was in 6th semester. Today I am going to share an upgrade version of it. In the upgrade version I used EEPROM of PIC 18f2550 so that data could be saved during electricity failure. Now take a look on the picture :
![]() |
Digital Voting Machine Circuit |
Description :
This Voting Machine conains 6 buttons for operation and two LEDs for notification.Candidate Category Button :
Button_RA0 : Candidate_1 .Button_RA1 : Candidate_2 .
Button_RA2 : Candidate_3 .
Control Button :
Button_RA4 : Control Button.Status Viewer Button :
Button_RC2 : Status View Button.Result Button :
Button_RA3 : Final Result Button.***Control Button :
This is the main controller of all other buttons. Without having permission of this button, any button can't perform. Without permission, reading instruction will not be taken. This will be placed in the presiding officer's room. Once he press the button and only one of these buttons can be permitted to perform only for one time. If any key or button is pressed, it works for one time and the system becomes disable automatically for voting until the presiding officer press control button again. So, one person will be able to vote for one time & voter will not be able to do that without permission of PO. Watch this video to understand completely.Video of Digital Voting Machine in Proteus :
![]() |
digital voting machine |
***Status Viewer Button :
For security reason we are hiding the voting status from the voter and Only the PO(presiding officer) can check this. At first PO have to press "Control Button " and LED 1 turns on when he can see the voting status by pressing "View Status" button. Current status will be shown only for a little time before getting back to the previous stage with turning on LED2.*** Result Button :
When OP decide to publish who is winner , he just need to press "control button" and after that need to press Final Result Button . After Showing result , it will be reset and all data will be erased .***Candidate Category Button :
When control button gives permission , only one of "candidate button category" buttons can perform, only for one time . After performing, this will disable the system . Generally these buttons are incremented by one during each action .
***LED 1 & LED 2 :
When LED1 remains on , others buttons can perform . When LED2 remains on, all buttons are disabled.
Source Code :
sbit LCD_RS at RB7_bit;
sbit LCD_EN at RB6_bit;
sbit LCD_D4 at RB5_bit;
sbit LCD_D5 at RB4_bit;
sbit LCD_D6 at RB3_bit;
sbit LCD_D7 at RB2_bit;
sbit LCD_RS_Direction at TRISB7_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D6_Direction at TRISB3_bit;
sbit LCD_D7_Direction at TRISB2_bit;
// End LCD module connections
short dat_can1=0,dat_can2=0,dat_can3=0,con=4;
char txt[]=" ";
char txt1[]="htp://pic18fmicrocontroller.blogspot.com";
char txt2[]=" Digital Voting Machine";
int i=0,j=0,chk=10;
char c1i='0',c1j='0',c1k='0';
char c2i,c2j,c2k;
char c3i,c3j,c3k;
int can_1adrs =15; // Keeping memory address for Candidate 1
int can_2adrs =19; // Keeping memory address for Candidate 2
int can_3adrs = 29; // Keeping memory address for Candidate 3
int chkk = 33,aq=0,b=0,aa=0,bb=0,cc=0;
char thirdchar(short dk){ ////find third Char of Short Data
aq=dk/100;
aa=aq*100;
aa=dk-aa;
if(aq==0)
{ aa=dk;
return '0'; }
if(aq==1) return '1';
if(aq==2) return '2';
if(aq==3) return '3';
if(aq==4) return '4';
if(aq==5) return '5';
if(aq==6) return '6';
if(aq==7) return '7';
if(aq==8) return '8';
if(aq==9) return '9';
}
char secondchar(short dk){ ////find Second Char of Short Data
b=aa/10;
bb=b*10;
bb=aa-bb;
if(b==0)
{ bb=dk;
return '0'; }
if(b==1) return '1';
if(b==2) return '2';
if(b==3) return '3';
if(b==4) return '4';
if(b==5) return '5';
if(b==6) return '6';
if(b==7) return '7';
if(b==8) return '8';
if(b==9) return '9';
}
char firstchar(short dk){ ////find first Char of Short Data
if(bb==0) return '0';
if(bb==1) return '1';
if(bb==2) return '2';
if(bb==3) return '3';
if(bb==4) return '4';
if(bb==5) return '5';
if(bb==6) return '6';
if(bb==7) return '7';
if(bb==8) return '8';
if(bb==9) return '9';
}
void main() {
ADCON1=0x0F;
CMCON=7;
TRISA.F0=1;
TRISA.F1=1;
TRISA.F2=1;
TRISA.F3=1;
TRISA.F4=1;
TRISC.F0=0;
TRISC.F1=0;
TRISC.F2=1;
Lcd_Init();
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF);
/////////////////////// Lcd Scroling Display Start
for(i=0;i<19;i++){
Lcd_Out(1,1,txt1);
Lcd_Out(2,1,txt2);
Lcd_Cmd(_LCD_SHIFT_LEFT);
delay_ms(200);
}
Lcd_Cmd(_LCD_CLEAR);
/////////////////////// Lcd Scroling Display End
for(j=0;j<16;j++){
Lcd_Cmd(_LCD_CLEAR);
txt[j]='.';
Lcd_Out(1,1," Starting...");
Lcd_Out(2,1,txt);
delay_ms(300);
}
dat_can1 = EEPROM_Read(can_1adrs); // reading previous data if avail able for Candidate 1
c1i=thirdchar(dat_can1); ///third
c1j=secondchar(dat_can1); //second
c1k=firstchar(dat_can1); //first
//// these functions should be called with this structure
/// I used this , because MikroC's short to str conversion didn't work .
dat_can2=EEPROM_Read(can_2adrs); // reading previous data if avail able for Candidate 2
c2i=thirdchar(dat_can2);
c2j=secondchar(dat_can1);
c2k=firstchar(dat_can1);
dat_can3=EEPROM_Read(can_3adrs); // reading previous data if avail able for Candidate 2
c3i=thirdchar(dat_can3);
c3j=secondchar(dat_can1);
c3k=firstchar(dat_can1);
Lcd_Cmd(_LCD_CLEAR);
if(dat_can3<=0){ // check if it runs for the first time , then set data null or 0
EEPROM_Write(can_3adrs,0);
dat_can3=EEPROM_Read(can_3adrs);
}
if(dat_can2<=0){ // check if it runs for the first time , then set data null or 0
EEPROM_Write(can_2adrs,0);
dat_can2=EEPROM_Read(can_2adrs);
}
if(dat_can1<=0){ // check if it runs for the first time , then set data null or 0
EEPROM_Write(can_1adrs,0);
dat_can1=EEPROM_Read(can_1adrs);
}
while(1){
c1i=thirdchar(dat_can1); // It is taking the last update data for Candidate 1
c1j=secondchar(dat_can1);
c1k=firstchar(dat_can1);
c2i=thirdchar(dat_can2); // It is taking the last update data for Candidate 2
c2j=secondchar(dat_can2);
c2k=firstchar(dat_can2);
c3i=thirdchar(dat_can3); // It is taking the last update data for Candidate 3
c3j=secondchar(dat_can3);
c3k=firstchar(dat_can3);
Lcd_Out(1,1,"C_1 C_2 C_3");
Lcd_Chr(2,1,'*');
Lcd_Chr(2,2,'*');
Lcd_Chr(2,3,'*');
Lcd_Chr(2,6,'*');
Lcd_Chr(2,7,'*');
Lcd_Chr(2,8,'*');
Lcd_Chr(2,11,'*');
Lcd_Chr(2,12,'*');
Lcd_Chr(2,13,'*');
if(PORTA.F4==0){ // if control button is pressed , it enables voting.
con=3;
}
if(con!=3){ // if control button is not pressed ,naturally it disables voting.
Lcd_Out(2,15,"DV");
PORTC.F0=0;
PORTC.F1=1; //LED2 is on
}
while(con==3){ // if control button is pressed , it enables voting.
Lcd_Out(2,15,"EV");
PORTC.F0=1; //LED1 is on
PORTC.F1=0;
if(PORTC.F2==0){ // when view status button is pressed
Lcd_Chr(2,1,c1i);
Lcd_Chr(2,2,c1j);
Lcd_Chr(2,3,c1k);
Lcd_Chr(2,6,c2i);
Lcd_Chr(2,7,c2j);
Lcd_Chr(2,8,c2k);
Lcd_Chr(2,11,c3i);
Lcd_Chr(2,12,c3j);
Lcd_Chr(2,13,c3k);
delay_ms(4000);
con=5; // con=5 makes disable voting
}
if(PORTA.F0==0){
dat_can1=dat_can1+1; // Candidate 1 variable is incrementing .
EEPROM_Write(can_1adrs,dat_can1); // writing the incremented value on EEPROM for Candidate 1
con=5; // con=5 makes disable voting
}
if(PORTA.F1==0){
dat_can2=dat_can2+1; // Candidate 2 variable is incrementing .
EEPROM_Write(can_2adrs,dat_can2); // writing the incremented value on EEPROM for Candidate 2
con=5; // con=5 makes disable voting
}
if(PORTA.F2==0){
dat_can3=dat_can3+1; // Candidate 3 variable is incrementing .
EEPROM_Write(can_3adrs,dat_can3); // writing the incremented value on EEPROM for Candidate 3
con=5; // con=5 makes disable voting
}
if(PORTA.F3==0){ // If Result Button is pressed .
Lcd_Cmd(_LCD_CLEAR);
for(j=1;j<17;j++){
Lcd_Out(1,1," Calculating...");
Lcd_Out(2,j,".");
delay_ms(200);
}
if(dat_can2>dat_can1&&dat_can2>dat_can3){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Winner is C_2");
Lcd_Out(2,1,"Congratulation!!");
delay_ms(5000);
Lcd_Out(1,1,"Winner is C_2");
Lcd_Out(2,1,"He got =");
delay_ms(5000);
Lcd_Cmd(_LCD_CLEAR);
dat_can2=0;
//Erasing All Datas
dat_can1=0;
dat_can3=0;
EEPROM_Write(can_1adrs,0);
EEPROM_Write(can_2adrs,0);
EEPROM_Write(can_3adrs,0);
}
else if(dat_can1>dat_can2&&dat_can1>dat_can3){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Winner is C_1");
Lcd_Out(2,1,"Congratulation!!");
delay_ms(5000);
Lcd_Cmd(_LCD_CLEAR);
dat_can2=0;
dat_can1=0;
dat_can3=0;
EEPROM_Write(can_1adrs,0);
EEPROM_Write(can_2adrs,0);
EEPROM_Write(can_3adrs,0);
}
else if(dat_can3>dat_can1&&dat_can3>dat_can2){
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Winner is C_3");
Lcd_Out(2,1,"Congratulation!!");
delay_ms(5000);
Lcd_Cmd(_LCD_CLEAR);
dat_can2=0;
dat_can1=0;
dat_can3=0;
EEPROM_Write(can_1adrs,0);
EEPROM_Write(can_2adrs,0);
EEPROM_Write(can_3adrs,0);
}
else{
Lcd_Cmd(_LCD_CLEAR);
Lcd_Out(1,1,"Something is");
Lcd_Out(2,1,"Worng!!!");
delay_ms(1000);
Lcd_Cmd(_LCD_CLEAR);
}
con=5;
}
}
}
}
Circuit Diagram :
![]() |
Digital Voting Machine Using Microcontroller |
Video of Digital Voting Machine in Practical :
did you do it in mikroC?
ReplyDeletedid you use mikroC for the code?
ReplyDeleteand sorry for late response.I couldn't have replied since commenting wasn't working for long time.
Deletehow can I use it with pic16f877a
ReplyDeleteYou just need to do some modification in your code. That's it.
DeleteI am impressed totally! I will try to apply this technique and these words to convince someone. :)
ReplyDeletehelps me in many ways.Thanks for posting this again. marine valve
ReplyDeleteMake sure that any company you use for your PCBs is willing to conduct an accurate PCB test, so that you can be sure of quality control. https://fastpcbunion.com/aluminum-pcb/ It belongs to the category of professional software and does come with a price; however, it is affordable and one of the most used software amongst medium-sized businesses in the present times.
ReplyDeleteIt should be noted that whilst ordering papers for sale at paper writing service, you can get unkind attitude. In case you feel that the bureau is trying to cheat you, don't buy term paper from it. machine
ReplyDeleteI was more than happy to uncover this great site. I need to thank you for your time due to this fantastic read!!
ReplyDeleteI definitely enjoyed every bit of it and I have you bookmarked to see new information on your blog.
humidifier dehumidifier combo
Use Darling Door Ducky - front load washer door prop - to prevent mold and mildew build-up and lessen odors front load washer door prop
ReplyDeleteThe good thing about these online escrow platform, is that everyone should upload their scanned ID, this guarantees security during the transactions.BTC near me
ReplyDeletethere is some error if i using mplab ide.how can i fix it
ReplyDeleteHow beautifully all the feelings have been conveyed through writing.
ReplyDeletenunique pandas
Awesome article, it was exceptionally helpful! I simply began in this and I'm becoming more acquainted with it better! Cheers, keep doing awesome! https://9xflix.World
ReplyDeleteWhat a sensational blog! This blog is too much amazing in all aspects. Especially, it looks awesome and the content available on it is utmost qualitative. https://pelisplus.world
ReplyDeleteHello I am so delighted I located your blog, I really located you by mistake, while I was watching on google for something else, Anyways I am here now and could just like to say thank for a tremendous post and a all round entertaining website. Please do keep up the great work. https://vegamovies.today
ReplyDeleteWow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also https://kuttymovies.website
ReplyDeleteI went to this website, and I believe that you have a plenty of excellent information, I have saved your site to my bookmarks. https://vegamovies.network
ReplyDeleteI wanted to thank you for this excellent read!! I definitely loved every little bit of it. I have you bookmarked your site to check out the new stuff you post. https://pedropolis.site
ReplyDeleteIt is extremely nice to see the greatest details presented in an easy and understanding manner. Goldshell KD6
ReplyDeleteHey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you. tyres
ReplyDeleteI just got to this amazing site not long ago. I was actually captured with the piece of resources you have got here. Big thumbs up for making such wonderful blog page! Trustee Seller Goldshell Kd6
ReplyDeleteWow! Such an amazing and helpful post this is.
ReplyDeletePoultry drugs distributors in Ethiopia
Email marketing remains an effective way to communicate with and nurture leads or customers.
ReplyDeleteDigital Marketing Agency
Inbound marketing leverages storytelling to create a strong brand narrative.
ReplyDeleteinbound marketing strategy