Arduino Electronic Voting Machine
Microcontroller-Based Digital Polling System & Dynamic Result Calculator
This Electronic Voting Machine (EVM) demonstration uses physical hardware to establish a simple and transparent digital voting system. Supporting up to three unique candidates, voters cast ballots via dedicated pull-up push buttons. The system registers each choice on an I2C 16x2 LCD module, triggers a confirmation tone via an active buzzer, and stores calculations in dynamic registers. Pressing the dedicated Administrator/Result button prints instant tally states and automatically determines the winner.
Gather the following components to assemble the interactive EVM circuit:
| Target Component Label | Structural Allocation Quantity | Functional Deployment Purpose |
|---|---|---|
| Arduino Uno R3 | 1 Unit | Master control unit executing debouncing routines and storing voter tally arrays. |
| 16x2 LCD with I2C Backplane | 1 Unit | Outputs progress states, system prompt guides, and tally results. |
| Tactile Push Buttons | 4 Units | Acts as physical input switches (Candidate 1, 2, 3, and Result trigger). |
| Active Buzzer | 1 Unit | Provides precise acoustic confirmation tones during cast procedures. |
| Breadboard & Hookup Wires | 1 Set | Builds reliable interconnect loops between processing, input, and output blocks. |
Connect the voting elements and screen displays directly to your microcontroller platform as outlined here:
| Device Terminal Pin Out | Arduino Target Pin Mapping | Functional Context |
|---|---|---|
| Candidate 1 Push Button | Digital Input Pin D2 | Sets candidate 1 voting input (active-low) |
| Candidate 2 Push Button | Digital Input Pin D3 | Sets candidate 2 voting input (active-low) |
| Candidate 3 Push Button | Digital Input Pin D4 | Sets candidate 3 voting input (active-low) |
| Result Button Switch | Digital Input Pin D5 | Triggers audit log and winner determination (active-low) |
| Active Buzzer (+) Pin | Digital Output Pin D8 | Drives confirmation beeps upon action trigger |
| LCD SDA Terminal | Analog Input Pin A4 | I2C Data Bus Connection |
| LCD SCL Terminal | Analog Input Pin A5 | I2C Clock Bus Connection |
| Common GND Bus | Power Ground Pin GND | Common reference loop for all push buttons & components |
Copy this program directly to your Arduino setup to manage pull-up inputs and execute real-time vote totals:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Button Pins
const int vote1 = 2;
const int vote2 = 3;
const int vote3 = 4;
const int resultBtn = 5;
// Buzzer
const int buzzer = 8;
// Vote Counters
int count1 = 0;
int count2 = 0;
int count3 = 0;
void setup()
{
pinMode(vote1, INPUT_PULLUP);
pinMode(vote2, INPUT_PULLUP);
pinMode(vote3, INPUT_PULLUP);
pinMode(resultBtn, INPUT_PULLUP);
pinMode(buzzer, OUTPUT);
lcd.init();
lcd.backlight();
lcd.setCursor(0,0);
lcd.print("Electronic");
lcd.setCursor(0,1);
lcd.print("Voting Machine");
delay(2000);
lcd.clear();
lcd.print("Ready to Vote");
}
void loop()
{
// Candidate 1
if(digitalRead(vote1)==LOW)
{
count1++;
voteSuccess("Candidate 1");
}
// Candidate 2
if(digitalRead(vote2)==LOW)
{
count2++;
voteSuccess("Candidate 2");
}
// Candidate 3
if(digitalRead(vote3)==LOW)
{
count3++;
voteSuccess("Candidate 3");
}
// Show Result
if(digitalRead(resultBtn)==LOW)
{
showResult();
}
}
void voteSuccess(String candidate)
{
tone(buzzer,1000);
delay(200);
noTone(buzzer);
lcd.clear();
lcd.print("Vote Recorded");
lcd.setCursor(0,1);
lcd.print(candidate);
delay(1500);
lcd.clear();
lcd.print("Ready to Vote");
while(
digitalRead(vote1)==LOW ||
digitalRead(vote2)==LOW ||
digitalRead(vote3)==LOW
);
}
void showResult()
{
lcd.clear();
lcd.print("C1:");
lcd.print(count1);
lcd.setCursor(8,0);
lcd.print("C2:");
lcd.print(count2);
lcd.setCursor(0,1);
lcd.print("C3:");
lcd.print(count3);
delay(5000);
lcd.clear();
if(count1>count2 && count1>count3)
{
lcd.print("Winner: C1");
}
else if(count2>count1 && count2>count3)
{
lcd.print("Winner: C2");
}
else if(count3>count1 && count3>count2)
{
lcd.print("Winner: C3");
}
else
{
lcd.print("Result: Tie");
}
tone(buzzer,1200);
delay(500);
noTone(buzzer);
delay(3000);
lcd.clear();
lcd.print("Ready to Vote");
while(digitalRead(resultBtn)==LOW);
}
INPUT_PULLUP logic, the button terminals are designed to run active-low. Connect the opposing terminal of all four push buttons directly to common system Ground (GND).

0 Comments