Introduction
In this article, we will guide you through the process of creating a secure and user-friendly voting system using Arduino, along with an R307 fingerprint sensor, a 16×2 LCD display, and a push button. By integrating biometric fingerprint recognition, clear visual feedback, and a simple user interface, we can develop an efficient and reliable voting system.
Component Need
S.N | Component's | Quantity |
1 | Arduino Nano | 1 |
2 | 16x2 LCD Display | 1 |
3 | R-307 Fingerprint Sensor | 1 |
4 | Push Button | 8 |
5 | Red Led | 1 |
6 | Green Led | 1 |
7 | Buzzer | 1 |
8 | Zero PCB | 1 |
9 | Power Supply | 1 |
Overview
- System Overview: The system uses an Arduino board as the main controller along with a fingerprint sensor module, an LCD display, push buttons, LEDs, and a buzzer. The Arduino communicates with the fingerprint sensor module to verify the identity of the voters.
- Enrollment Process: Before the voting process begins, voters need to enrol their fingerprints. The Fingerprints are to be stored in the EEPROM memory.
- Voting Process: Once the enrollment is complete, the voting process can begin. Voters place their fingers on the fingerprint sensor, and the system verifies their identity by matching the captured fingerprint with the stored fingerprints in the EEPROM.
- Security and Authentication: The fingerprint sensor provides a high level of security and authentication, as each person’s fingerprint is unique.
- Vote Counting: The system keeps track of the votes by updating the vote count in the EEPROM. The LCD display shows the current vote counts for each candidate.
- System Reset: The system includes a reset functionality that allows all stored fingerprints and vote counts to be cleared, providing a fresh start for a new voting session.
Circuit Diagram
- Arduino board: This is the main microcontroller board that controls the entire system.
- LiquidCrystal: Here we used a 16×2 LCD display. The LCD display is connected to the Arduino board using six digital pins (12, 11, 10, 9, 8, 7).
- Adafruit Fingerprint Sensor: This is a fingerprint sensor module used for fingerprint identification. It communicates with the Arduino board over the serial interface.
- Push buttons: The code defines several push buttons connected to the Arduino board. The pins used for these buttons are defined as
enroll
,del
,up
,down
,match
,sw1
,sw2
,sw3
, andresultsw
. These buttons are used for various functions such as enrolling fingerprints, deleting fingerprints, and controlling the voting process. - LEDs: The code uses LEDs to indicate the status of the system. The pins used for the LEDs are defined as
indVote
andindFinger
. - Buzzer: A buzzer is used to provide audio feedback. The pin used for the buzzer is defined as
buzzer
. - EEPROM: The code utilizes EEPROM memory to store voting records and other data.
Source Code
Important Library
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
//Prateek //http://justdoelectronics.com #include <EEPROM.h> #include <LiquidCrystal.h> LiquidCrystal lcd(12, 11, 10, 9, 8, 7); #include <Adafruit_Fingerprint.h> uint8_t id; Adafruit_Fingerprint finger = Adafruit_Fingerprint(&Serial); #define enroll 14 #define del 15 #define up 16 #define down 17 #define match 18 #define indVote 6 #define sw1 5 #define sw2 2 #define sw3 3 #define resultsw 4 #define indFinger 7 #define buzzer 6 #define records 25 int vote1, vote2, vote3; int flag; void setup() { delay(1000); pinMode(enroll, INPUT_PULLUP); pinMode(up, INPUT_PULLUP); pinMode(down, INPUT_PULLUP); pinMode(del, INPUT_PULLUP); pinMode(match, INPUT_PULLUP); pinMode(sw1, INPUT_PULLUP); pinMode(sw2, INPUT_PULLUP); pinMode(sw3, INPUT_PULLUP); pinMode(resultsw, INPUT_PULLUP); pinMode(buzzer, OUTPUT); pinMode(indVote, OUTPUT); pinMode(indFinger, OUTPUT); lcd.begin(16, 2); if (digitalRead(resultsw) == 0) { for (int i = 0; i < records; i++) EEPROM.write(i + 10, 0xff); EEPROM.write(0, 0); EEPROM.write(1, 0); EEPROM.write(2, 0); lcd.clear(); lcd.print("System Reset"); delay(1000); } lcd.clear(); lcd.print("Voting Machine"); lcd.setCursor(0, 1); lcd.print("by Finger Print"); delay(2000); lcd.clear(); lcd.print("JustDoElectronics"); lcd.setCursor(0, 1); lcd.print("Prateek"); delay(2000); if (EEPROM.read(0) == 0xff) EEPROM.write(0, 0); if (EEPROM.read(1) == 0xff) EEPROM.write(1, 0); if (EEPROM.read(1) == 0xff) EEPROM.write(1, 0); //finger.begin(57600); Serial.begin(57600); lcd.clear(); lcd.print("Finding Module"); lcd.setCursor(0, 1); delay(1000); if (finger.verifyPassword()) { lcd.clear(); lcd.print("Found Module "); delay(1000); } else { lcd.clear(); lcd.print("module not Found"); lcd.setCursor(0, 1); lcd.print("Check Connections"); while (1) ; } lcd.clear(); lcd.setCursor(0, 0); lcd.print("Cn1"); lcd.setCursor(4, 0); lcd.print("Cn2"); lcd.setCursor(8, 0); lcd.print("Cn3"); lcd.setCursor(12, 0); lcd.print("Cn4"); lcd.setCursor(0, 1); vote1 = EEPROM.read(0); lcd.print(vote1); lcd.setCursor(6, 1); vote2 = EEPROM.read(1); lcd.print(vote2); lcd.setCursor(12, 1); vote3 = EEPROM.read(2); lcd.print(vote3); delay(2000); } void loop() { lcd.setCursor(0, 0); lcd.print("Press Match Key "); lcd.setCursor(0, 1); lcd.print("to start system"); digitalWrite(indVote, LOW); digitalWrite(indFinger, LOW); if (digitalRead(match) == 0) { digitalWrite(buzzer, HIGH); delay(200); digitalWrite(buzzer, LOW); digitalWrite(indFinger, HIGH); for (int i = 0; i < 3; i++) { lcd.clear(); lcd.print("Place Finger"); delay(2000); int result = getFingerprintIDez(); if (result >= 0) { flag = 0; for (int i = 0; i < records; i++) { if (result == EEPROM.read(i + 10)) { lcd.clear(); lcd.print("Authorised Voter"); lcd.setCursor(0, 1); lcd.print("Please Wait...."); delay(1000); Vote(); EEPROM.write(i + 10, 0xff); flag = 1; return; } } if (flag == 0) { lcd.clear(); lcd.print("Already Voted"); //lcd.setCursor(0,1); //lcd.print("") digitalWrite(buzzer, HIGH); delay(5000); digitalWrite(buzzer, LOW); return; } } } lcd.clear(); } checkKeys(); delay(1000); } void checkKeys() { if (digitalRead(enroll) == 0) { lcd.clear(); lcd.print("Please Wait"); delay(1000); while (digitalRead(enroll) == 0) ; Enroll(); } else if (digitalRead(del) == 0) { lcd.clear(); lcd.print("Please Wait"); delay(1000); delet(); } } void Enroll() { int count = 0; lcd.clear(); lcd.print("Enter Finger ID:"); while (1) { lcd.setCursor(0, 1); lcd.print(count); if (digitalRead(up) == 0) { count++; if (count > 25) count = 0; delay(500); } else if (digitalRead(down) == 0) { count--; if (count < 0) count = 25; delay(500); } else if (digitalRead(del) == 0) { id = count; getFingerprintEnroll(); for (int i = 0; i < records; i++) { if (EEPROM.read(i + 10) == 0xff) { EEPROM.write(i + 10, id); break; } } return; } else if (digitalRead(enroll) == 0) { return; } } } void delet() { int count = 0; lcd.clear(); lcd.print("Enter Finger ID"); while (1) { lcd.setCursor(0, 1); lcd.print(count); if (digitalRead(up) == 0) { count++; if (count > 25) count = 0; delay(500); } else if (digitalRead(down) == 0) { count--; if (count < 0) count = 25; delay(500); } else if (digitalRead(del) == 0) { id = count; deleteFingerprint(id); for (int i = 0; i < records; i++) { if (EEPROM.read(i + 10) == id) { EEPROM.write(i + 10, 0xff); break; } } return; } else if (digitalRead(enroll) == 0) { return; } } } uint8_t getFingerprintEnroll() { int p = -1; lcd.clear(); lcd.print("finger ID:"); lcd.print(id); lcd.setCursor(0, 1); lcd.print("Place Finger"); delay(2000); while (p != FINGERPRINT_OK) { p = finger.getImage(); switch (p) { case FINGERPRINT_OK: //Serial.println("Image taken"); lcd.clear(); lcd.print("Image taken"); break; case FINGERPRINT_NOFINGER: //Serial.println("No Finger"); lcd.clear(); lcd.print("No Finger"); break; case FINGERPRINT_PACKETRECIEVEERR: //Serial.println("Communication error"); lcd.clear(); lcd.print("Comm Error"); break; case FINGERPRINT_IMAGEFAIL: //Serial.println("Imaging error"); lcd.clear(); lcd.print("Imaging Error"); break; default: //Serial.println("Unknown error"); lcd.clear(); lcd.print("Unknown Error"); break; } } // OK success! p = finger.image2Tz(1); switch (p) { case FINGERPRINT_OK: //Serial.println("Image converted"); lcd.clear(); lcd.print("Image converted"); break; case FINGERPRINT_IMAGEMESS: //Serial.println("Image too messy"); lcd.clear(); lcd.print("Image too messy"); return p; case FINGERPRINT_PACKETRECIEVEERR: //Serial.println("Communication error"); lcd.clear(); lcd.print("Comm Error"); return p; case FINGERPRINT_FEATUREFAIL: //Serial.println("Could not find fingerprint features"); lcd.clear(); lcd.print("Feature Not Found"); return p; case FINGERPRINT_INVALIDIMAGE: //Serial.println("Could not find fingerprint features"); lcd.clear(); lcd.print("Feature Not Found"); return p; default: //Serial.println("Unknown error"); lcd.clear(); lcd.print("Unknown Error"); return p; } //Serial.println("Remove finger"); lcd.clear(); lcd.print("Remove Finger"); delay(2000); p = 0; while (p != FINGERPRINT_NOFINGER) { p = finger.getImage(); } p = -1; lcd.clear(); lcd.print("Place Finger"); lcd.setCursor(0, 1); lcd.print(" Again"); while (p != FINGERPRINT_OK) { p = finger.getImage(); switch (p) { case FINGERPRINT_OK: break; case FINGERPRINT_NOFINGER: break; case FINGERPRINT_PACKETRECIEVEERR: break; case FINGERPRINT_IMAGEFAIL: break; default: return; } } p = finger.image2Tz(2); switch (p) { case FINGERPRINT_OK: break; case FINGERPRINT_IMAGEMESS: return p; case FINGERPRINT_PACKETRECIEVEERR: return p; case FINGERPRINT_FEATUREFAIL: return p; case FINGERPRINT_INVALIDIMAGE: return p; default: return p; } p = finger.createModel(); if (p == FINGERPRINT_OK) { //Serial.println("Prints matched!"); } else if (p == FINGERPRINT_PACKETRECIEVEERR) { //Serial.println("Communication error"); return p; } else if (p == FINGERPRINT_ENROLLMISMATCH) { //Serial.println("Fingerprints did not match"); return p; } else { //Serial.println("Unknown error"); return p; } //Serial.print("ID "); //Serial.println(id); p = finger.storeModel(id); if (p == FINGERPRINT_OK) { //Serial.println("Stored!"); lcd.clear(); lcd.print("Stored!"); delay(2000); } else if (p == FINGERPRINT_PACKETRECIEVEERR) { //Serial.println("Communication error"); return p; } else if (p == FINGERPRINT_BADLOCATION) { //Serial.println("Could not store in that location"); return p; } else if (p == FINGERPRINT_FLASHERR) { //Serial.println("Error writing to flash"); return p; } else { //Serial.println("Unknown error"); return p; } } int getFingerprintIDez() { uint8_t p = finger.getImage(); if (p != FINGERPRINT_OK) return -1; p = finger.image2Tz(); if (p != FINGERPRINT_OK) return -1; p = finger.fingerFastSearch(); if (p != FINGERPRINT_OK) { lcd.clear(); lcd.print("Finger Not Found"); lcd.setCursor(0, 1); lcd.print("Try Later"); delay(2000); return -1; } // found a match! //Serial.print("Found ID #"); //Serial.print(finger.fingerID); return finger.fingerID; } uint8_t deleteFingerprint(uint8_t id) { uint8_t p = -1; lcd.clear(); lcd.print("Please wait"); p = finger.deleteModel(id); if (p == FINGERPRINT_OK) { //Serial.println("Deleted!"); lcd.clear(); lcd.print("Figer Deleted"); lcd.setCursor(0, 1); lcd.print("Successfully"); delay(1000); } else { //Serial.print("Something Wrong"); lcd.clear(); lcd.print("Something Wrong"); lcd.setCursor(0, 1); lcd.print("Try Again Later"); delay(2000); return p; } } void Vote() { lcd.clear(); lcd.print("Please Place"); lcd.setCursor(0, 1); lcd.print("Your Vote"); digitalWrite(indVote, HIGH); digitalWrite(indFinger, LOW); digitalWrite(buzzer, HIGH); delay(500); digitalWrite(buzzer, LOW); delay(1000); while (1) { if (digitalRead(sw1) == 0) { vote1++; voteSubmit(1); EEPROM.write(0, vote1); while (digitalRead(sw1) == 0) ; return; } if (digitalRead(sw2) == 0) { vote2++; voteSubmit(2); EEPROM.write(1, vote2); while (digitalRead(sw2) == 0) ; return; } if (digitalRead(sw3) == 0) { vote3++; voteSubmit(3); EEPROM.write(2, vote3); while (digitalRead(sw3) == 0) ; return; } if (digitalRead(resultsw) == 0) { lcd.clear(); lcd.setCursor(0, 0); lcd.print("Can1"); lcd.setCursor(6, 0); lcd.print("Can2"); lcd.setCursor(12, 0); lcd.print("Can3"); for (int i = 0; i < 3; i++) { lcd.setCursor(i * 6, 1); lcd.print(EEPROM.read(i)); } delay(2000); int vote = vote1 + vote2 + vote3; if (vote) { if ((vote1 > vote2 && vote1 > vote3)) { lcd.clear(); lcd.print("Can1 Wins"); delay(2000); lcd.clear(); } else if (vote2 > vote1 && vote2 > vote3) { lcd.clear(); lcd.print("Can2 Wins"); delay(2000); lcd.clear(); } else if ((vote3 > vote1 && vote3 > vote2)) { lcd.clear(); lcd.print("Can3 Wins"); delay(2000); lcd.clear(); } else { lcd.clear(); lcd.print(" Tie Up Or "); lcd.setCursor(0, 1); lcd.print(" No Result "); delay(1000); lcd.clear(); } } else { lcd.clear(); lcd.print("No Voting...."); delay(1000); lcd.clear(); } vote1 = 0; vote2 = 0; vote3 = 0; vote = 0; lcd.clear(); return; } } digitalWrite(indVote, LOW); } void voteSubmit(int cn) { lcd.clear(); if (cn == 1) lcd.print("Can1"); else if (cn == 2) lcd.print("Can2"); else if (cn == 3) lcd.print("Can3"); lcd.setCursor(0, 1); lcd.print("Vote Submitted"); digitalWrite(buzzer, HIGH); delay(1000); digitalWrite(buzzer, LOW); digitalWrite(indVote, LOW); return; } |
Demo Photo
When turned on the system the LCD will display the welcome message and is ready to used.
If the fingerprint Sensor is detected properly Then the LCD will display a Module Found message.
Now you enrol your fingers one by one with the serial number
Video
Conclusion
The Fingerprint-based Voting System using Arduino offers a reliable and secure method for conducting voting processes. By using fingerprint authentication, it ensures that each person can vote only once and reduces the risk of fraudulent activities. However, it is important to consider additional security measures and legal requirements when implementing such a system in real-world scenarios.
Arduino Based Projects