Arduino UNO Fingerprint-Based Voting System with LCD Display and Buzzer Notification
View and Edit Project In Cirkit Designer
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
- Description: A standard pushbutton used for user input.
- Pins: Pin 1 (in), Pin 2 (in), Pin 3 (out), Pin 4 (out)
Arduino UNO
- Description: A microcontroller board based on the ATmega328P.
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0-A5, SCL, SDA, AREF, D0-D13
Buzzer
- Description: An electronic buzzer for audio signaling.
- Pins: PIN, GND
I2C LCD 16x2 Screen
- Description: A 16x2 character LCD display with an I2C interface.
- Pins: SCL, SDA, VCC (5V), GND, VDD, VO, RS, RW, E, D0-D7, BLA, BLK
Fingerprint Scanner
- Description: A biometric sensor for fingerprint detection and identification.
- Pins: VCC, TX, RX, GND
Wiring Details
Pushbutton
- Pin 1 (in): Connected to the corresponding analog input pin on the Arduino UNO (A0, A1, A2, A3, A4, D4, D5, D6, D7).
- Pin 3 (out): Connected to the GND pin on the Arduino UNO.
Arduino UNO
- A0-A5, D2-D7: Connected to the input pins of pushbuttons.
- 5V: Provides power to the I2C LCD screen and the fingerprint scanner.
- GND: Common ground for the buzzer, pushbuttons, I2C LCD screen, and fingerprint scanner.
- D2, D3: Connected to the TX and RX pins of the fingerprint scanner for serial communication.
- D4-D7: Connected to the input pins of pushbuttons.
Buzzer
- PIN: Connected to the D7 pin on the Arduino UNO.
- GND: Connected to the common ground.
I2C LCD 16x2 Screen
- SCL, SDA: Connected to the corresponding SCL and SDA pins on the Arduino UNO for I2C communication.
- VCC (5V): Powered by the 5V pin on the Arduino UNO.
- GND: Connected to the common ground.
Fingerprint Scanner
- VCC: Powered by the 5V pin on the Arduino UNO.
- TX, RX: Connected to the D2 and D3 pins on the Arduino UNO for serial communication.
- GND: Connected to the common ground.
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)