我們都非常熟悉電子投票機,您的投票以電子方式登記,您無需使用選票即可在選舉中投票。今天,安全性是一個主要問題,還需要確保某人不能投票兩次,因此可以通過引入基于指紋的投票來解決這個問題,在這種情況下,一個人可以根據(jù)他的指紋獲得授權(quán)。這也將阻止虛假投票。所以今天我們正在 使用Arduino構(gòu)建基于指紋的生物識別投票機 。
所需組件:
投票機中的指紋傳感器模塊:
指紋 傳感器模塊或指紋掃描儀是一種模塊 ,用于捕獲手指的指紋圖像,然后將其轉(zhuǎn)換為等效模板,并將它們保存到Arduino所選ID(位置)上的內(nèi)存中。在這里,所有過程都由Arduino控制,例如拍攝指紋圖像,將其轉(zhuǎn)換為模板和存儲位置等。
在這個指紋投票機電路中,我們使用指紋傳感器模塊通過在系統(tǒng)中輸入手指來驗證真正的選民。在這里,我們使用 5 個按鈕來匹配、注冊/返回、刪除/確定、向上和向下。注冊和德爾鍵在這里具有雙重功能。注冊鍵用于將新的手指印模注冊到系統(tǒng)和返回功能中。意味著當(dāng)用戶想要注冊新手指時,他/她需要按注冊鍵,然后LCD詢問用戶想要存儲指紋輸出的ID或位置。現(xiàn)在,如果此時用戶不想繼續(xù),那么他/她可以再次按注冊鍵返回(這次注冊鍵表現(xiàn)為后退鍵)。表示注冊密鑰同時具有注冊和返回功能。DEL/OK 鍵還具有相同的雙重功能,就像用戶注冊新手指時一樣,他/她需要使用另外兩個鍵(即向上和向下)選擇手指 ID 或位置,現(xiàn)在用戶需要按 DEL/OK 鍵(這次此鍵的行為類似于確定)以繼續(xù)使用選定的 ID 或位置。匹配鍵用于每當(dāng)選民想要投票時,他/她需要首先通過手指在指紋傳感器上對真正的選民進行身份驗證,如果他/她通過了此身份驗證,那么他/她就可以投票。
工作說明:
對于初學(xué)者來說,這個用于選舉的生物識別投票系統(tǒng)的工作有點復(fù)雜。首先,用戶需要在按鈕/鍵的幫助下注冊手指或投票者(在此代碼中,選民的最大限制為 25)。為此,用戶需要按REGISTER鍵,然后LCD要求輸入手指將成為商店的位置/ ID。所以現(xiàn)在用戶需要使用向上/向下鍵輸入ID(位置)。選擇位置/ID 后,用戶需要按確定鍵(DEL 鍵)。現(xiàn)在,液晶屏將要求將手指放在指紋模塊上。現(xiàn)在用戶需要將手指放在指紋模塊上。然后液晶屏將要求將手指從指紋模塊中取出,并再次要求放置手指。現(xiàn)在用戶需要再次將手指放在指紋模塊上。現(xiàn)在,指紋模塊獲取圖像并將其轉(zhuǎn)換為模板,并通過選定的ID將其存儲在指紋模塊的內(nèi)存中。現(xiàn)在選民將被登記,他/她可以投票。通過同樣的方法,所有選民都可以登記到系統(tǒng)中。
現(xiàn)在,如果用戶想要刪除或刪除任何存儲的ID,那么他/她需要按DEL鍵,按DEL鍵后,LCD將要求選擇位置意味著選擇要刪除的ID。現(xiàn)在用戶需要選擇ID并按確定鍵(相同的DEL鍵)。現(xiàn)在LCD會讓您知道手指已成功刪除。
投票流程:
現(xiàn)在,當(dāng)用戶想要投票時,他/她需要按匹配鍵,然后蜂鳴器將發(fā)出嗶嗶聲,LED也會發(fā)光,LCD將要求將手指放在指紋模塊上。現(xiàn)在Arduino會給你三次嘗試把你的手指。將手指放在指紋模塊上后,指紋模塊捕獲手指圖像,發(fā)現(xiàn)其ID存在于系統(tǒng)中。如果檢測到手指 ID,則 LCD 將顯示授權(quán)選民。這意味著用戶有權(quán)投票。然后系統(tǒng)進入下一階段進行投票。現(xiàn)在綠色LED會亮起,這意味著現(xiàn)在選民可以通過按重新當(dāng)選的鍵(來自本演示中的紅色面包板)為他們的候選人投票。現(xiàn)在,如果同一選民想再次投票,那么系統(tǒng)將顯示它 “已投票”。 表示同一選民無法再次投票,蜂鳴器將發(fā)出 5 秒的嗶嗶聲。如果任何非注冊用戶想要投票,則指紋模塊將不會在系統(tǒng)中檢測到其ID,LCD將顯示“未找到指紋”。
這里的CAN1,CAN2,CAN3代表候選人1,候選人2和候選人3,他們參加了選舉。
電路說明:
這個基于指紋的投票機項目的電路非常簡單,其中包含用于控制整個項目過程的Arduino,用于注冊,刪除,選擇ID和投票目的的按鈕,用于警報的蜂鳴器,用于指示的LED和用于指示選民并顯示結(jié)果的16x2 LCD。黃色 LED 表示指紋模塊已準(zhǔn)備好拍攝手指圖像,綠色 LED 表示系統(tǒng)已準(zhǔn)備好進行投票或查看結(jié)果。
按鈕直接連接到 Arduino 的引腳 A0(注冊)、A1(DEL)、A2(向上)、A3(向下)和 A4(匹配)、D5(Can1)、D4(Can2)、D3(Can3)、D2(結(jié)果)相對于接地。黃色 LED 通過 1k 電阻連接到 Arduino 的數(shù)字引腳 D7 相對于接地,綠色 LED 以相同的方法連接到 Arduino 的 D6。指紋模塊的 Rx 和 Tx 直接連接到 Arduino 的串行引腳 Tx 和 Rx。5v 電源用于為取自 Arduino 板的指紋模塊供電。A5 處還連接了一個蜂鳴器。16x2 LCD 配置為 4 位模式,其 RS、EN、D4、D5、D6 和 D7 直接連接到 Arduino 的數(shù)字引腳 D13、D12、D11、D10、D9 和 D8。
程序說明:
在設(shè)置功能中,我們已經(jīng)給出了定義引腳的方向,并啟動了LCD和指紋模塊。
之后,在 void loop() 函數(shù)中,我們等待檢查鍵并按匹配鍵開始指紋進行輸入并將捕獲的圖像ID與存儲的ID進行比較。如果發(fā)生匹配,則繼續(xù)下一步。
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++)
..... .....
....... ....
給定 void checkKeys() 函數(shù)用于檢查是否按下注冊或 DEL 鍵以及按下時該怎么做。如果按下 ENROL 鍵,則調(diào)用 Enroll( ) 函數(shù)并按下 DEL 鍵,則調(diào)用 delete() 函數(shù)。
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();
}
}
給定函數(shù)用于輸入要刪除的 ID 并調(diào)用uint8_t *deleteFingerprint(uint8_t id) *函數(shù),該函數(shù)將從記錄中刪除手指。
void delet()
{
int count=0;
lcd.clear();
lcd.print("Delete Finger ");
lcd.setCursor(0,1);
lcd.print("Location:");
while(1)
{
lcd.setCursor(9,1);
lcd.print(count);
if(digitalRead(up) == 0)
{
count++;
if(count>25)
count=0;
delay(500);
}
.... .....
..... .....
給定功能用于從所選ID的記錄中刪除指紋。
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;
}
}
給定功能用于獲取指紋圖像并將其轉(zhuǎn)換為模板,并通過選定的ID將其保存到指紋模塊存儲器中。
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();
..... .....
....... ....
給定函數(shù)用于投票和顯示結(jié)果:
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)
#include
#include
LiquidCrystal lcd(13,12,11,10,9,8);
#include
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 4
#define sw3 3
#define resultsw 2
#define indFinger 7
#define buzzer 19
#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;iEEPROM.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("Circuit Digest");
lcd.setCursor(0,1);
lcd.print("Saddam Khan");
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())
{
//Serial.println("Found fingerprint sensor!");
lcd.clear();
lcd.print("Found Module ");
delay(1000);
}
else
{
//Serial.println("Did not find fingerprint sensor :(");
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
{
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;iif(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;iif(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();
}
//Serial.print("ID "); //Serial.println(id);
p = -1;
//Serial.println("Place same finger again");
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:
//Serial.println("Image taken");
break;
case FINGERPRINT_NOFINGER:
//Serial.print(".");
break;
case FINGERPRINT_PACKETRECIEVEERR:
//Serial.println("Communication error");
break;
case FINGERPRINT_IMAGEFAIL:
//Serial.println("Imaging error");
break;
default:
//Serial.println("Unknown error");
return;
}
}
// OK success!
p = finger.image2Tz(2);
switch (p) {
case FINGERPRINT_OK:
//Serial.println("Image converted");
break;
case FINGERPRINT_IMAGEMESS:
//Serial.println("Image too messy");
return p;
case FINGERPRINT_PACKETRECIEVEERR:
//Serial.println("Communication error");
return p;
case FINGERPRINT_FEATUREFAIL:
//Serial.println("Could not find fingerprint features");
return p;
case FINGERPRINT_INVALIDIMAGE:
//Serial.println("Could not find fingerprint features");
return p;
default:
//Serial.println("Unknown error");
return p;
}
// OK converted!
//Serial.print("Creating model for #"); //Serial.println(id);
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;
}
-
生物識別
+關(guān)注
關(guān)注
3文章
1210瀏覽量
52518 -
指紋傳感器
+關(guān)注
關(guān)注
6文章
195瀏覽量
63470 -
Arduino
+關(guān)注
關(guān)注
188文章
6468瀏覽量
186952
發(fā)布評論請先 登錄
相關(guān)推薦
評論