Voting system (8051 microcontroller)


voting system or electoral system is a method by which voters make a choice between options, often in an election or on a policy referendum. A voting system enforces rules to ensure valid voting, and how votes are counted and aggregated to yield a final result.Electronic voting machine has now replaced the traditional mechanism of voting due to several advantages like security, automatic counting etc. This project presents a way to develop an electronic voting machine which displays the count of votes on a 16x2 LCD interface. A user can get his/her vote register through a set of switches (one for each candidate). After every cast of vote, the subsequent count can be seen on LCD. The circuit uses AT89C51 microcontroller and the code for the project has been written in C.

Electronic voting (also known as e-voting) is voting using electronic systems to aid casting and counting votes.

Electronic voting technology can include punched cards, optical scan voting systems and specialized voting kiosks (including self-contained direct-recording electronic voting systems, or DRE). It can also involve transmission of ballots and votes via telephones, private computer networks, or the Internet.

In general, two main types of e-Voting can be identified:

  • e-voting which is physically supervised by representatives of governmental or independent electoral authorities (e.g. electronic voting machines located at polling stations);
  • remote e-Voting where voting is performed within the voter's sole influence, and is not physically supervised by representatives of governmental authorities (e.g. voting from one's personal computer, mobile phone, television via the internet (also called i-voting)).

Electronic voting technology can speed the counting of ballots and can provide improved accessibility for disabled voters. However, there has been contention, especially in the United States, that electronic voting, especially DRE voting, could facilitate electoral fraud.

A direct-recording electronic (DRE) voting machine records votes by means of a ballot display provided with mechanical or electro-optical components that can be activated by the voter (typically buttons or a touchscreen); that processes data with computer software; and that records voting data and ballot images in memory components. After the election it produces a tabulation of the voting data stored in a removable memory component and as printed copy. The system may also provide a means for transmitting individual ballots or vote totals to a central location for consolidating and reporting results from precincts at the central location. These systems use a precinct count method that tabulates ballots at the polling place. They typically tabulate ballots as they are cast and print the results after the close of polling.


Before, we proceed, i highly recommend you to read detailed information about IR sensor module which we created, 8051 microcontroller intro & programming environment setup and Motor driving circuit.

FYI, These projects are very large and can have various input devices (medium) from which we can have the voting opinion of voters like Finger print scanning, which not only gives the votor opinion but also his/her id, next is touch screens with nice GUI. internet didgital signature and so on. Obviously! we will be making very complex system at last, but my main aim is to make things easier to you, not flash your eyes with complex things at once.

So, our task we will be "To make a voting platform of 2 parties(candidates) which compete for 10 votes". For this, currently we are not using RF IDs/readers, good gui application (like Qt), expensive microcontrollers like arm cortex8 and so on with linux, instead we are using 8051 architecture microcontroller development board, so that you can learn with less budget. For the  input part, we will use Matrix keypad shown by me in this article.

Now for further information i want you to see my youtube video embedded here. In this video, i have explained the working of this project.

I hope that, you have clear understanding about the circuit through this video. I have not given a seperate circuit diagram to you people because i want you to understand the working and not just see and make circuits. But after this video, you could still not figure out how to make circuit on this board or at your custom board then for that, i have made a small PDF file for all the steps you should follow, while making this circuit. you can download this file from hereWith this, you can also download the codes of 8051 microcontroller interfacing and specially the code for this project on this git link. 

A bit code explaination

Below given code snippet of this project.

Here, you can see the logicial part of this program, where partyA, partyB represents input voting switch for CandidateA and CandidateB. ac and bc hold the number of votes given to A and B candidate (in short A count and B count)

 you can see that after checking unlock condition and ok switch pressed condition, we inititialized the place variable and with that waited for switch to come up (released by user).  After button s released, then signal led is blinked off. With this, whole code is caluculated with digits which we recieved earlier by some other functions. Then password is compared with any variable. In this image, i have just checked the last digit that is 4. But in production, you will check all digits, in short whole number formed. You can see in the code, that we are checking the counts of vote to the value 10. It means that the candidate who will get his/her 10 votes before others, will be the winner. Usually, this kind of method is not used in government sector.

Morever, in next setp of advancing this project, we will take an array for votes count of each candidate (in case of higher number). This is what, i have done for traffic light controller code. Here, this might seem very unprofessional code (and yes it is) but for learning phase, it doesnot matter. later, i will tell you about much higher level microcontroller and good programming techniques)

Obviously, i cant explain you whole code line by line. Its so long, but i have already divided this project into smaller modules. You can find articles about them in Learning sections. Atleast, you must read about 7-Segment Display and Matrix keypad. And also, i if you dont know how to compile and then burn the hex file into your microcontroller, then follow this tutorial.

I hope this article helped you. Please feel free to comment below or contact me, for any query. :)