Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Fingerprint-Based Voting System with LCD Display and Buzzer Notification

View and Edit Project In Cirkit DesignerImage of Arduino UNO Fingerprint-Based Voting System with LCD Display and Buzzer Notification

Circuit Documentation

Summary of the Circuit

This circuit is designed to create an electronic voting system that utilizes a fingerprint scanner for voter identification and pushbuttons for vote input. The system includes an Arduino UNO microcontroller, a buzzer for audio feedback, an I2C LCD screen for visual feedback, and a fingerprint scanner for user authentication. The Arduino UNO reads inputs from the pushbuttons and controls the buzzer and LCD screen accordingly. The fingerprint scanner is used to ensure that each voter is allowed to vote only once.

Component List

Pushbutton

Arduino UNO

Buzzer

I2C LCD 16x2 Screen

Fingerprint Scanner

Wiring Details

Pushbutton

Arduino UNO

Buzzer

I2C LCD 16x2 Screen

Fingerprint Scanner

Documented Code

#include <Adafruit_Fingerprint.h>
#include <LiquidCrystal_I2C.h>  // Include the I2C library for the LCD
#include <SoftwareSerial.h>
#include <Servo.h>
#include <EEPROM.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);  // LCD with I2C address
SoftwareSerial fingerPrint(2, 3);    // RX and TX pins for fingerprint sensor
Servo myServo;

Adafruit_Fingerprint finger = Adafruit_Fingerprint(&fingerPrint);

// Button and pin definitions
#define enroll A1
#define del A0
#define up A2
#define down A3
#define startButton 6         // Button to start fingerprint scan
#define resultbutton A4
#define candidate1 4
#define candidate2 A5
#define candidate3 A6
#define servoPin 5
#define buzzer 8

uint8_t id;
int voteCount1, voteCount2, voteCount3;

void setup() 
{
    delay(1000);
    myServo.attach(servoPin);
    myServo.write(180);  // Close the servo initially

    // Set pin modes
    pinMode(enroll, INPUT_PULLUP);
    pinMode(up, INPUT_PULLUP); 
    pinMode(down, INPUT_PULLUP); 
    pinMode(del, INPUT_PULLUP); 
    pinMode(buzzer, OUTPUT);
    pinMode(candidate1, INPUT_PULLUP);
    pinMode(candidate2, INPUT_PULLUP);
    pinMode(candidate3, INPUT_PULLUP);
    pinMode(resultbutton, INPUT_PULLUP);
    pinMode(startButton, INPUT_PULLUP);

    // Initialize the LCD with the correct parameters
    lcd.begin(16, 2);
    lcd.print("Voting system");
    lcd.setCursor(0, 1);
    lcd.print("by Finger Print");
    delay(2000);
    lcd.clear();

    finger.begin(57600);
    Serial.begin(9600);

    lcd.print("Finding Module");
    delay(1000);
    if (finger.verifyPassword()) 
    {
        Serial.println("Found fingerprint sensor!");
        lcd.clear();
        lcd.print("Module Found");
        delay(1000);
    } 
    else 
    {
        Serial.println("Fingerprint sensor not found.");
        lcd.clear();
        lcd.print("Module Not Found");
        lcd.setCursor(0, 1);
        lcd.print("Check Connections");
        while (1);
    }

    // Load stored vote counts from EEPROM
    voteCount1 = EEPROM.read(0);
    voteCount2 = EEPROM.read(1);
    voteCount3 = EEPROM.read(2);
}

void loop() 
{
    lcd.setCursor(0, 0);
    lcd.print("Press Start ");
    lcd.setCursor(0, 1);
    lcd.print("to begin voting");

    if (digitalRead(startButton) == LOW)
    {
        lcd.clear();
        lcd.print("Place Finger");
        delay(2000);

        if (getFingerprintIDez() >= 0)
        {
            digitalWrite(buzzer, HIGH);
            delay(500);
            digitalWrite(buzzer, LOW);

            lcd.clear();
            lcd.print("Allowed");
            lcd.setCursor(0, 1);
            lcd.print("Vote Now");

            handleVoting();

            myServo.write(0);  // Open the servo
            delay(5000);
            myServo.write(180);  // Close the servo

            lcd.clear();
            lcd.print("Gate Closed");
        }
        delay(1000);
    }

    checkKeys();
    delay(500);  // Debounce delay
}

void handleVoting()
{
    lcd.clear();
    lcd.print("Vote: C1 C2 C3");

    while (true) 
    {
        if (digitalRead(candidate1) == LOW) 
        {
            voteCount1++;
            EEPROM.update(0, voteCount1);
            lcd.clear();
            lcd.print("Voted: Candidate 1");
            delay(2000);
            break;
        }
        else if (digitalRead(candidate2) == LOW) 
        {
            voteCount2++;
            EEPROM.update(1, voteCount2);
            lcd.clear();
            lcd.print("Voted: Candidate 2");
            delay(2000);
            break;
        }
        else if (digitalRead(candidate3) == LOW) 
        {
            voteCount3++;
            EEPROM.update(2, voteCount3);
            lcd.clear();
            lcd.print("Voted: Candidate 3");
            delay(2000);
            break;
        }
    }
}

void showResults()
{
    lcd.clear();
    lcd.print("Results:");
    lcd.setCursor(0, 1);
    lcd.print("C1:");
    lcd.print(voteCount1);
    lcd.setCursor(6, 1);
    lcd.print("C2:");
    lcd.print(voteCount2);
    lcd.setCursor(12, 1);
    lcd.print("C3:");
    lcd.print(voteCount3);
    delay(5000);
}

void checkKeys()
{
    if (digitalRead(enroll) == LOW)
    {
        lcd.clear();
        lcd.print("Please Wait");
        delay(1000);
        Enroll();
    }
    else if (digitalRead(del) == LOW)
    {
        lcd.clear();
        lcd.print("Please Wait");
        delay(1000);
        delet();
    }
    else if (digitalRead(resultbutton) == LOW)
    {
        showResults();
    }
}

void Enroll()
{
    int count = 0;
    lcd.clear();
    lcd.print("Enroll Finger");
    lcd.setCursor(0, 1);
    lcd.print("Location:");

    while (true)
    {
        lcd.setCursor(9, 1);
        lcd.print(count);

        if (digitalRead(up) == LOW)
        {
            count = (count + 1) % 25;  // Circular buffer
            delay(500);
        }
        else if (digitalRead(down) == LOW)
        {
            count = (count > 0) ? count - 1 : 24;
            delay(500);
        }
        else if (digitalRead(del) == LOW)
        {
            id = count;
            getFingerprintEnroll();
            return;
        }
        else if (digitalRead(enroll) == LOW)