我们都非常熟悉电子投票机,您的投票以电子方式登记,您无需使用选票即可在选举中投票。今天,安全性是一个主要问题,还需要确保某人不能投票两次,因此可以通过引入基于指纹的投票来解决这个问题,在这种情况下,一个人可以根据他的指纹获得授权。这也将阻止虚假投票。所以今天我们正在 使用Arduino构建基于指纹的生物识别投票机 。
指纹 传感器模块或指纹扫描仪是一种模块 ,用于捕获手指的指纹图像,然后将其转换为等效模板,并将它们保存到Arduino所选ID(位置)上的内存中。在这里,所有过程都由Arduino控制,例如拍摄指纹图像,将其转换为模板和存储位置等。
在这个指纹投票机电路中,我们使用指纹传感器模块通过在系统中输入手指来验证真正的选民。在这里,我们使用 5 个按钮来匹配、注册/返回、删除/确定、向上和向下。注册和德尔键在这里具有双重功能。注册键用于将新的手指印模注册到系统和返回功能中。意味着当用户想要注册新手指时,他/她需要按注册键,然后LCD询问用户想要存储指纹输出的ID或位置。现在,如果此时用户不想继续,那么他/她可以再次按注册键返回(这次注册键表现为后退键)。表示注册密钥同时具有注册和返回功能。DEL/OK 键还具有相同的双重功能,就像用户注册新手指时一样,他/她需要使用另外两个键(即向上和向下)选择手指 ID 或位置,现在用户需要按 DEL/OK 键(这次此键的行为类似于确定)以继续使用选定的 ID 或位置。匹配键用于每当选民想要投票时,他/她需要首先通过手指在指纹传感器上对真正的选民进行身份验证,如果他/她通过了此身份验证,那么他/她就可以投票。
对于初学者来说,这个用于选举的生物识别投票系统的工作有点复杂。首先,用户需要在按钮/键的帮助下注册手指或投票者(在此代码中,选民的最大限制为 25)。为此,用户需要按REGISTER键,然后LCD要求输入手指将成为商店的位置/ ID。所以现在用户需要使用向上/向下键输入ID(位置)。选择位置/ID 后,用户需要按确定键(DEL 键)。现在,液晶屏将要求将手指放在指纹模块上。现在用户需要将手指放在指纹模块上。然后液晶屏将要求将手指从指纹模块中取出,并再次要求放置手指。现在用户需要再次将手指放在指纹模块上。现在,指纹模块获取图像并将其转换为模板,并通过选定的ID将其存储在指纹模块的内存中。现在选民将被登记,他/她可以投票。通过同样的方法,所有选民都可以登记到系统中。
现在,如果用户想要删除或删除任何存储的ID,那么他/她需要按DEL键,按DEL键后,LCD将要求选择位置意味着选择要删除的ID。现在用户需要选择ID并按确定键(相同的DEL键)。现在LCD会让您知道手指已成功删除。
投票流程:
现在,当用户想要投票时,他/她需要按匹配键,然后蜂鸣器将发出哔哔声,LED也会发光,LCD将要求将手指放在指纹模块上。现在Arduino会给你三次尝试把你的手指。将手指放在指纹模块上后,指纹模块捕获手指图像,发现其ID存在于系统中。如果检测到手指 ID,则 LCD 将显示授权选民。这意味着用户有权投票。然后系统进入下一阶段进行投票。现在绿色LED会亮起,这意味着现在选民可以通过按重新当选的键(来自本演示中的红色面包板)为他们的候选人投票。现在,如果同一选民想再次投票,那么系统将显示它 “已投票”。 表示同一选民无法再次投票,蜂鸣器将发出 5 秒的哔哔声。如果任何非注册用户想要投票,则指纹模块将不会在系统中检测到其ID,LCD将显示“未找到指纹”。
这里的CAN1,CAN2,CAN3代表候选人1,候选人2和候选人3,他们参加了选举。
这个基于指纹的投票机项目的电路非常简单,其中包含用于控制整个项目过程的Arduino,用于注册,删除,选择ID和投票目的的按钮,用于警报的蜂鸣器,用于指示的LED和用于指示选民并显示结果的16x2 LCD。黄色 LED 表示指纹模块已准备好拍摄手指图像,绿色 LED 表示系统已准备好进行投票或查看结果。
按钮直接连接到 Arduino 的引脚 A0(注册)、A1(DEL)、A2(向上)、A3(向下)和 A4(匹配)、D5(Can1)、D4(Can2)、D3(Can3)、D2(结果)相对于接地。黄色 LED 通过 1k 电阻连接到 Arduino 的数字引脚 D7 相对于接地,绿色 LED 以相同的方法连接到 Arduino 的 D6。指纹模块的 Rx 和 Tx 直接连接到 Arduino 的串行引脚 Tx 和 Rx。5v 电源用于为取自 Arduino 板的指纹模块供电。A5 处还连接了一个蜂鸣器。16x2 LCD 配置为 4 位模式,其 RS、EN、D4、D5、D6 和 D7 直接连接到 Arduino 的数字引脚 D13、D12、D11、D10、D9 和 D8。
在设置功能中,我们已经给出了定义引脚的方向,并启动了LCD和指纹模块。
之后,在 void loop() 函数中,我们等待检查键并按匹配键开始指纹进行输入并将捕获的图像ID与存储的ID进行比较。如果发生匹配,则继续下一步。
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() 函数用于检查是否按下注册或 DEL 键以及按下时该怎么做。如果按下 ENROL 键,则调用 Enroll( ) 函数并按下 DEL 键,则调用 delete() 函数。
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();
}
}
给定函数用于输入要删除的 ID 并调用uint8_t *deleteFingerprint(uint8_t id) *函数,该函数将从记录中删除手指。
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;
}
}
给定功能用于获取指纹图像并将其转换为模板,并通过选定的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();
..... .....
....... ....
给定函数用于投票和显示结果:
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;
}
全部0条评论
快来发表一下你的评论吧 !