top of page
Writer's pictureSanskruti Ashtikar

Electronic Voting Machine Using 8051 Microcontroller

Updated: 3 days ago

Introduction


Electronic Voting Machines (EVMs) have revolutionized the voting process by making it faster, more reliable, and tamper-proof. This article describes the design and implementation of an EVM using the 8051 microcontroller. The system allows voters to cast their votes electronically and ensures that each vote is accurately counted and recorded.





Components Required


  1. 8051 Microcontroller

  2. 4x4 Matrix Keypad

  3. 16x2 LCD Display

  4. LEDs

  5. Buzzer

  6. Push Buttons

  7. Power Supply

  8. Connecting Wires

  9. Resistors, Capacitors, and other passive components


System Overview


The electronic voting machine consists of a keypad for voter input, an LCD display to show instructions and results, LEDs to indicate the status of the voting process, and a buzzer for audio feedback. The 8051 microcontroller handles all the tasks, including reading inputs from the keypad, updating the display, and storing the vote counts.


Circuit Diagram


Note: Add a circuit diagram image as described above.


Working Principle


  1. Initialization: The system initializes by displaying a welcome message on the LCD and resetting all vote counts to zero.

  2. Voting Process:

  3. The voter is prompted to press a button corresponding to their candidate of choice.

  4. Each button on the keypad is mapped to a candidate.

  5. When a button is pressed, the corresponding LED lights up, the vote is recorded, and the buzzer sounds to confirm the vote.

  6. Vote Counting:

  7. The microcontroller increments the vote count for the selected candidate.

  8. After voting, the system can display the total votes for each candidate on the LCD.

  9. Security Features:

  10. The system ensures that each voter can vote only once by using a simple locking mechanism (e.g., a unique voter ID system can be added for more complex implementations).


Circuit Design


1. Keypad Interface:

  • Connect the rows and columns of the 4x4 matrix keypad to the digital I/O pins of the 8051 microcontroller.

  • Configure the microcontroller to scan the keypad matrix to detect key presses.

2. LCD Display:

  • Connect the data pins of the 16x2 LCD to the designated port of the 8051 microcontroller.

  • Connect the control pins (RS, RW, E) to appropriate pins of the microcontroller.

  • Initialize the LCD in 4-bit mode for displaying messages.

3. LEDs and Buzzer:

  • Connect LEDs to the output pins of the microcontroller to indicate vote casting.

  • Connect the buzzer to another output pin to provide audio feedback.

4. Push Buttons:

  • Connect push buttons to additional input pins for system control functions like resetting the vote count or starting a new voting session.


Programming the 8051 Microcontroller


The program for the 8051 microcontroller is written in Embedded C. The code involves initializing the keypad, LCD, LEDs, and buzzer, as well as handling vote counting and display updates.



#include <reg51.h>
// Define connections
sbit LED1 = P1^0;
sbit LED2 = P1^1;
sbit LED3 = P1^2;
sbit LED4 = P1^3;
sbit BUZZER = P1^4;
sbit RS = P2^0;
sbit RW = P2^1;
sbit EN = P2^2;
sbit KEYPAD_ROW_1 = P3^0;
sbit KEYPAD_ROW_2 = P3^1;
sbit KEYPAD_ROW_3 = P3^2;
sbit KEYPAD_ROW_4 = P3^3;
sbit KEYPAD_COL_1 = P3^4;
sbit KEYPAD_COL_2 = P3^5;
sbit KEYPAD_COL_3 = P3^6;
sbit KEYPAD_COL_4 = P3^7;
// Function prototypes
void lcd_init(void);
void lcd_cmd(unsigned char);
void lcd_data(unsigned char);
void lcd_string(unsigned char *);
void delay(unsigned int);
char keypad_read(void);
void count_vote(char);
// Vote counts
unsigned int vote_count[4] = {0, 0, 0, 0};
void main() {
    char key;
    lcd_init();
    lcd_string("EVM System Ready");
    delay(2000);
    lcd_cmd(0x01);  // Clear display
    
    while(1) {
        lcd_string("Press to Vote");
        key = keypad_read();
        if(key != 0) {
            count_vote(key);
        }
    }
}
void lcd_init() {
    lcd_cmd(0x38);  // 2 lines, 5x7 matrix
    lcd_cmd(0x0C);  // Display on, cursor off
    lcd_cmd(0x06);  // Increment cursor
    lcd_cmd(0x01);  // Clear display
}
void lcd_cmd(unsigned char cmd) {
    P2 = cmd;
    RS = 0;
    RW = 0;
    EN = 1;
    delay(1);
    EN = 0;
}


void lcd_data(unsigned char data) {
    P2 = data;
    RS = 1;
    RW = 0;
    EN = 1;
    delay(1);
    EN = 0;
}
void lcd_string(unsigned char *str) {
    while(*str) {
        lcd_data(*str++);
    }
}
void delay(unsigned int ms) {
    unsigned int i, j;
    for(i = 0; i < ms; i++) {
        for(j = 0; j < 1275; j++);
    }
}
char keypad_read() {
    KEYPAD_ROW_1 = 0; KEYPAD_ROW_2 = 1; KEYPAD_ROW_3 = 1; KEYPAD_ROW_4 = 1;
    if(KEYPAD_COL_1 == 0) { delay(100); while(KEYPAD_COL_1 == 0); return '1'; }
    if(KEYPAD_COL_2 == 0) { delay(100); while(KEYPAD_COL_2 == 0); return '2'; }
    if(KEYPAD_COL_3 == 0) { delay(100); while(KEYPAD_COL_3 == 0); return '3'; }
    if(KEYPAD_COL_4 == 0) { delay(100); while(KEYPAD_COL_4 == 0); return 'A'; }
    KEYPAD_ROW_1 = 1; KEYPAD_ROW_2 = 0; KEYPAD_ROW_3 = 1; KEYPAD_ROW_4 = 1;
    if(KEYPAD_COL_1 == 0) { delay(100); while(KEYPAD_COL_1 == 0); return '4'; }
    if(KEYPAD_COL_2 == 0) { delay(100); while(KEYPAD_COL_2 == 0); return '5'; }
    if(KEYPAD_COL_3 == 0) { delay(100); while(KEYPAD_COL_3 == 0); return '6'; }
    if(KEYPAD_COL_4 == 0) { delay(100); while(KEYPAD_COL_4 == 0); return 'B'; }
    KEYPAD_ROW_1 = 1; KEYPAD_ROW_2 = 1; KEYPAD_ROW_3 = 0; KEYPAD_ROW_4 = 1;
    if(KEYPAD_COL_1 == 0) { delay(100); while(KEYPAD_COL_1 == 0); return '7'; }
    if(KEYPAD_COL_2 == 0) { delay(100); while(KEYPAD_COL_2 == 0); return '8'; }
    if(KEYPAD_COL_3 == 0) { delay(100); while(KEYPAD_COL_3 == 0); return '9'; }
    if(KEYPAD_COL_4 == 0) { delay(100); while(KEYPAD_COL_4 == 0); return 'C'; }
    KEYPAD_ROW_1 = 1; KEYPAD_ROW_2 = 1; KEYPAD_ROW_3 = 1; KEYPAD_ROW_4 = 0;
    if(KEYPAD_COL_1 == 0) { delay(100); while(KEYPAD_COL_1 == 0); return '*'; }
    if(KEYPAD_COL_2 == 0) { delay(100); while(KEYPAD_COL_2 == 0); return '0'; }
    if(KEYPAD_COL_3 == 0) { delay(100); while(KEYPAD_COL_3 == 0); return '#'; }
    if(KEYPAD_COL_4 == 0) { delay(100); while(KEYPAD_COL_4 == 0); return 'D'; }
    return 0;
}


void count_vote(char key) {
    switch(key) {
        case '1':
            vote_count[0]++;
            LED1 = 1;
            lcd_cmd(0x01);  // Clear display
            lcd_string("Vote for 1 recorded");
            break;
        case '2':
            vote_count[1]++;
            LED2 = 1;
            lcd_cmd(0x01);  // Clear display
            lcd_string("Vote for 2 recorded");
            break;
        case '3':
            vote_count[2]++;
            LED3 = 1;
            lcd_cmd(0x01);  // Clear display
            lcd_string("Vote for 3 recorded");
            break;
        case '4':
            vote_count[3]++;
            LED4 = 1;
            lcd_cmd(0x01);  // Clear display
            lcd_string("Vote for 4 recorded");
            break;
        default:
            break;
    }
    BUZZER = 1;
    delay(500);
    BUZZER = 0;
    LED1 = 0; LED2 = 0; LED3 = 0; LED4 = 0;
    delay(1000);
    lcd_cmd(0x01);  // Clear display
}

Conclusion


An electronic voting machine using the 8051 microcontroller provides a reliable and efficient means of conducting elections. By automating the vote casting and counting processes, it ensures accuracy and transparency. This article outlines the basic components, circuit design, and programming necessary to build an EVM. With further enhancements such as security features and network connectivity, this system can be adapted for larger-scale applications.


Want us to guide you through your project or make the project for you ?







Create Various Projects

Check out our Free Arduino Projects Playlist - Arduino Projects 

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects 

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects 

Check out our Free IoT Projects Playlist - IoT Projects 

Check out our Free Home Automation Projects Playlist - Home Automation Projects 

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects 



0 views0 comments

Related Posts

See All

Comments