Arduino Electronic Voting Machine
Microcontroller-Based Digital Polling Engine & Real-Time Winner Analysis
This physical prototype models the fundamental operations of an Electronic Voting Machine (EVM) using an Arduino Uno[cite: 28]. Voters can securely cast ballots for one of three unique candidates via dedicated tactile input buttons, triggering immediate dual-mode confirmation (an audible beep alongside real-time LCD feedback)[cite: 27, 28]. Pressing an administrator result button tallies all stored values to instantly declare the statistical winner or signal a tied vote sequence on the display panel[cite: 27, 28].
Assemble these hardware components to build your digital polling prototype[cite: 28]:
| Target Component Label | Structural Allocation Quantity | Functional Deployment Purpose |
|---|---|---|
| Arduino Uno | 1 Unit | Primary processing core that scans inputs, tallies data, and manages display outputs[cite: 28]. |
| 16x2 I2C LCD Display | 1 Unit | Primary display rendering system states, ballot inputs, and final results[cite: 28]. |
| Tactile Push Buttons | 4 Units | User interfaces for casting votes (3 candidates) and requesting final tallies (1 administrator button)[cite: 28]. |
| Active Buzzer | 1 Unit | Generates brief audio tones to verify each successfully cast ballot[cite: 28]. |
| Breadboard & Hookup Wires | 1 Set | Supplies structural routing pathways and 5V system power distribution[cite: 28]. |
Connect your hardware components to the Arduino Uno exactly as structured in the deployment table below[cite: 28]:
| Input / Output Pin | Arduino Target Pin Mapping | Functional Context |
|---|---|---|
| Candidate 1 Button | Digital Input Pin D2 | Interruptible line utilizing internal pull-up resistor[cite: 28] |
| Candidate 2 Button | Digital Input Pin D3 | Interruptible line utilizing internal pull-up resistor[cite: 28] |
| Candidate 3 Button | Digital Input Pin D4 | General I/O line utilizing internal pull-up resistor[cite: 28] |
| Result Tally Button | Digital Input Pin D5 | Administrator panel trigger using internal pull-up[cite: 28] |
| Active Buzzer (+) | Digital Output Pin D8 | Drives confirmation and winner celebration tones[cite: 28] |
| LCD SDA Terminal | Analog Input Pin A4 | I2C Data Bus Interface Pin[cite: 28] |
| LCD SCL Terminal | Analog Input Pin A5 | I2C Clock Bus Interface Pin[cite: 28] |
Upload this robust voting machine program to your microcontroller board using the Arduino IDE[cite: 28]:
#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);
}
Wire and LiquidCrystal_I2C libraries are installed in your workspace before compiling to prevent physical display communication issues[cite: 28].

0 Comments