Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Electronic voting machine using seven segment multiplexing with 8051 microcontroller (AT89C51)

By Himanshu Choudhary August 12, 2010

 

This topic presents a basic approach to develop an electronic machine. The idea is to display the count of votes on a set of seven segment displays. A set of switches are provided through which a user can cast vote. After every cast of vote, the subsequent count can be seen on the seven segments. The segments and switches are controlled through AT89C51. For every candidate, a segment has been provided.
 

 

 


 

 

This voting machine is designed for four candidates. The provision of casting vote has been provided by means of four tactile switches. These switches take manual inputs from the user and transfer them to the pins of controller. Based on these inputs, the vote count for different candidates is increased by AT89C51.
 
sbit switch_1=P3^2;//Input pins for four candidates
sbit switch_2=P3^3;
sbit switch_3=P3^4;
sbit switch_4=P3^5;
 
To display the vote count, four seven segment displays are also connected to the microcontroller (refer seven segment interfacing with AT89C51). The count value for each candidate is sent to the corresponding segment. The four counts appear continuously by multiplexing these segments through AT89C51.
 
unsigned int digi_val[10]={0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10};
unsigned int dig_1,dig_2,dig_3,dig_4;
 
Pins 2-5 of the port P3 are configured to take inputs through switches connected to them. The data pins of the seven segments are connected to port P2. Pins 0-3, of port P1, are configured as output to act as control/enable pins of the seven segments.
 

 

Project Source Code

###

// Program to make voting machine using seven segment
#include <reg51.h>
#define msec 1

sbit switch_1=P3^2;//Input pins for four candidates
sbit switch_2=P3^3;
sbit switch_3=P3^4;
sbit switch_4=P3^5;

sbit dig_ctrl_4=P1^0;//Declare the control pins of seven segments
sbit dig_ctrl_3=P1^1;
sbit dig_ctrl_2=P1^2;
sbit dig_ctrl_1=P1^3;

unsigned int vote_1,vote_2,vote_3,vote_4;

unsigned int digi_val[10]={0x40,0xF9,0x24,0x30,0x19,0x12,0x02,0xF8,0x00,0x10};
unsigned int dig_1,dig_2,dig_3,dig_4;



void delay(unsigned int count)// Time delay function
{
unsigned int j,k;
for (j=0;j<=count;j++)
for (k=0;k<=50;k++);
}

void digi_out(unsigned int current_num)// Funtion to display total votes
{
unsigned int dig_disp;
dig_disp=current_num;
P2 = digi_val[current_num];
delay(msec);
}


void calc_vote()// Funtion to count the number of votes
{
while(1)
{
if (switch_1==0)
{
while (switch_1 == 0);//check if switch 1 is pressed
{
vote_1 = vote_1 + 1;
if(vote_1==10)
vote_1=0;
}
}

if (switch_2==0)//check if switch 2 is pressed
{
while (switch_2 == 0);
{
vote_2 = vote_2 + 1;
if(vote_2==10)
vote_2=0;
}
}

if (switch_3==0)//check if switch 3 is pressed
{
while (switch_3 == 0);
{
vote_3 = vote_3 + 1;
if(vote_3==10)
vote_3=0;
}
}

if (switch_4==0)//check if switch 4 is pressed
{
while (switch_4 == 0);
{
vote_4 = vote_4 + 1;
if(vote_4==10)
vote_4=0;
}
}

dig_ctrl_1 = 1;
dig_ctrl_3 = dig_ctrl_2 = dig_ctrl_4 = 0;
digi_out(vote_1);
dig_ctrl_2 = 1;
dig_ctrl_4 = dig_ctrl_3 = dig_ctrl_1 = 0;
digi_out(vote_2);
dig_ctrl_3 = 1;
dig_ctrl_2 = dig_ctrl_4 = dig_ctrl_1 = 0;
digi_out(vote_3);
dig_ctrl_4 = 1;
dig_ctrl_3 = dig_ctrl_2 = dig_ctrl_1 = 0;
digi_out(vote_4);
}
}


void main()
{
vote_1 = vote_2 = vote_3 = vote_4 = 0;
switch_1 = switch_2 = switch_3 = switch_4 = 1;// Initialize the input pins
while(1)
{
calc_vote();
}
}
###

Circuit Diagrams

Circuit-Diagram-Electronic-Voting-Machine-Using-Seven-Segment-Multiplexing-8051-Microcontroller-AT89C51

Project Components

  • AT89C51 Microcontroller
  • Seven Segment Display
  • Transistor BC547


Filed Under: 8051 Microcontroller
Tagged With: 8051, microcontroller, seven segment, voting machine
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on Electro-Tech-Online.com and EDAboard.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

  • GanFet power switch starts burning after 20 sec
  • RF-DC rectifier impedance matching
  • Inverting OpAmp - basic circuit question
  • 12VAC to 12VDC 5A on 250ft 12AWG
  • Precision CAD Drafting Services for Architectural & Engineering Projects

RSS Electro-Tech-Online.com Discussions

  • LED circuit for 1/6 scale diorama
  • stud mount Schottky diodes
  • Hi Guys
  • using a RTC in SF basic
  • Can I use this charger in every country?

Featured – Designing of Audio Amplifiers part 9 series

  • Basics of Audio Amplifier – 1/9
  • Designing 250 Milli Watt Audio Power Amplifier – 2/9
  • Designing 1 Watt Audio Power Amplifier – 3/9
  • Designing a Bass Boost Amplifier – 4/9
  • Designing a 6 Watt Car Audio Amplifier – 5/9
  • Design a low power amplifier for headphones- 6/9

Recent Articles

  • Fischer connector system adds ratchet locking system designed for 300g shock resistance
  • Littelfuse introduces tactile switch with enhanced bracket peg design for mounting strength
  • Infineon releases GaN switch with monolithic bidirectional design
  • Sienna Semiconductor data converters feature sample rates from 20 to 250 Msps
  • Delta’s 5,500 W power supplies achieve 97.5% energy efficiency for AI servers

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronics Projects and Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe