功能:
研究?jī)?nèi)容:本課題以單片機(jī)為核心采用C語(yǔ)言來(lái)開(kāi)發(fā)一指紋電子密碼鎖。系統(tǒng)擬在Altium?Designer9開(kāi)發(fā)平臺(tái)上設(shè)計(jì)原理圖,并繪制PCB并制成單片機(jī)開(kāi)發(fā)板,然后根據(jù)原理圖將相關(guān)元器件焊接到開(kāi)發(fā)板上。軟件部分在Keil?uVision4開(kāi)發(fā)平臺(tái)上進(jìn)行相關(guān)代碼的編寫(xiě)和調(diào)試。然后利用串口助手工具將代碼下載到開(kāi)發(fā)板進(jìn)行運(yùn)行,觀(guān)察硬件各模塊是否可以正常運(yùn)行。以及測(cè)試結(jié)果是否能夠滿(mǎn)足需求,便于及時(shí)調(diào)整設(shè)計(jì)。
課題的主要任務(wù)是設(shè)計(jì)出一個(gè)可以錄入指紋,并可對(duì)錄入指紋進(jìn)行匹配比較,如果正確即可開(kāi)鎖。
- 設(shè)置有管理員密碼,管理員密碼內(nèi)置不可修改,密碼具有掉電存儲(chǔ)功能。
- 輸入管理員密碼后進(jìn)入指紋錄制模式,錄入自己的指紋
- 錄制成功后,支持指紋開(kāi)鎖,指紋匹配成功后,繼電器吸合表示開(kāi)門(mén),并且語(yǔ)音提示開(kāi)鎖成功
- 當(dāng)遇到震動(dòng)時(shí),語(yǔ)音提示,請(qǐng)勿強(qiáng)行開(kāi)鎖,并且可以通過(guò)sim模塊發(fā)送報(bào)警短信
- 單片機(jī)內(nèi)置用戶(hù)密碼,匹配成功后可以通過(guò)app使用密碼開(kāi)鎖。
重點(diǎn)難點(diǎn):指紋的錄制與識(shí)別,語(yǔ)音提示,并且具有報(bào)警系統(tǒng),當(dāng)遇到震動(dòng)時(shí)時(shí)可以發(fā)出語(yǔ)音報(bào)警和sim短信報(bào)警,硬件元器件較多使用了大量串口,pcb排版要注意,避免各個(gè)部件之間的干擾。
電路原理圖:
資料內(nèi)容包括:
部分程序:
#include <intrins.h>
#include <INTRINS.H>
#include"lcd1602.h"
#include "string.h"
sbit led= P0^7;
sbit buz= P2^0;
sbit j1= P2^1;
sbit shock= P2^2;
sbit in_1 = P1^4; //°′?ü
sbit in_2 = P1^5;
sbit in_3 = P1^6;
sbit in_4 = P1^7;
sbit out_1 = P3^7; //°′?ü
sbit out_2 = P3^6;
sbit out_3 = P3^5;
sbit out_4 = P3^4;
unsigned char password[6] = {1,2,3,4,5,6};
unsigned char password2[6] = {1,2,3,4,5,6};
unsigned char runCount=0;
unsigned char R_flag=0;
unsigned char number = 0;
unsigned char recSign = 0;//?óê?êy?Y±ê??
unsigned char rec[16]; //?óê?êy?Y?o′?
unsigned char recIndex = 0;//?óê?êy?Y
unsigned char recTemp = 0;//?óê?êy?Y
char zf[3];
char rec_num = 0; //?óê?êy?Y??êy
uchar sign = 0;
#define Max_User 10
#define error 2
#define S2RI 0x01 ? ?//′??ú2?óê??D?????ó±ê????
#define S2TI 0x02 ? ?//′??ú2·¢?í?D?????ó±ê????
unsigned char num_4x4=0;
char KeyVal = 0;
int count = 0; //?¨ê±?÷±?á?
#define Max_User 10
#define error 2
char user_num = 0;
unsigned char ?? ?SaveNumber=0,searchnum=0;
unsigned int ??? ?SearchNumber=0;
unsigned int ?? ?clk0=0;
unsigned int ?? ?rec_number = 0; //?óê?êy?Y
unsigned char str[3]={0,'?','?'};
bit modeflag=0,clearallflag=0,changeflag=0;//??è??aê?±e?£ê?£?è?1??a1?a??è??????£ê?,????è?ò?′?SaveNumber++
//3£ó???á??¨ò?/
//Verify ?Password ? £o?é?¤éè±???ê??úá?
unsigned char code VPWD[16]={16,0X01 ,0Xff,0xff,0xff,0xff, 0x01,0,7,0x13,0x00,0x00,0x00,0x00,0x00,0x1b};?? ? //???í12??
//éè??éè±???ê??úá?
unsigned char code STWD[16]={16,0X01 ,0Xff,0xff,0xff,0xff, 0x01,0,7,0x12,0x00,0x00,0x00,0x00,0x00,0x1a};?? ? //???í12??
//GetImage ? ? ? ? ? £oì?2aê???2¢′ó′??D?÷é??áè?í???
unsigned char code GIMG[14]={12, 0X01 ,0Xff,0xff,0xff,0xff, 0x01, 0,3,1,0x00,0x05};?? ?//???í12??
//Gen Templet1 ? ? ? ?£o?ù?Y?-ê?í???éú3é????ì??÷1
unsigned char code GENT1[14]={13,0X01 ,0Xff,0xff,0xff,0xff,0x01,0,4,2,1,0x00,0x08};?? ?//???í12??
//Gen Templet2 ? ? ? ?£o?ù?Y?-ê?í???éú3é????ì??÷2
unsigned char code GENT2[14]={13,0X01 ,0Xff,0xff,0xff,0xff,0x01,0,4,2,2,0x00,0x09}; //???í12??
//Search Finger ? ? ?£oò?CharBufferA?òCharBufferB?Dμ?ì??÷???t???÷?????ò2?·??????a
unsigned char code SEAT[18]={17, ?0X01 ,0Xff,0xff,0xff,0xff, 0x01, ? 0,8, 4,1,0,0, ? ?0,0x65, ?0x00,0x73};?? ?//???í12??
//Merge Templet ? ? ?;??CharBufferAó?CharBufferB?Dμ?ì??÷???to?2¢éú3é?£°?£??á1?′?óúModelBuffer?£
unsigned char code MERG[14]={12, ?0X01 ,0Xff,0xff,0xff,0xff, 0x01, ?0,3,5 , 0x00,0x09};//???í12??
//Store Templet ? ? ?£o??ModelBuffer?Dμ????t′¢′?μ?flash?????a?D
unsigned char code STOR[16]={15, ?0X01 ,0Xff,0xff,0xff,0xff, 0x01, ?0,6,6,2, ? ? 0x00,0x00, ? ? 0x00,0x0f}; //???í12??
//DEL one templet
unsigned char code DELE_one[16]={16, 0X01 ,0Xff,0xff,0xff,0xff, 0x01, ? 0,7, ?0x0c, ? ?0x00,0x00, 0,1, 0x00,0x15};
//DEL templet ? ? ?;?????????a
unsigned char code DELE_all[12]={12,0X01 ,0Xff,0xff,0xff,0xff, 0x01, 0,3, ?0x0d,0x00,0x11};
//3£ó???á??¨ò?-------?áê?///
//oê?¨ò?
#define FALSE 0
#define TURE ?1
//×′ì??¨ò?±í
#define on ? ??? ?1
#define off ? ?? ?0
#define MAX_NUMBER ? ?63
#define _Nop() ?_nop_()
unsigned char ?? ??? ? ?FifoNumber=0;
unsigned char ? FIFO[MAX_NUMBER+1]={0};
//oê?¨ò?------------?áê?
/*********1oá???óê±3ìDò**********/
void delay1ms(unsigned int t)
{
unsigned int i,j;
for(i=0;i<t;i++)
for(j=0;j<120*6;j++)
;
}
void delay10ms(unsigned int c) ? //?ó2? 0us
{
unsigned char a, b;
//--cò??-?ú′?μY1yà′μ?ê±oòò??-?3?μá?£??ùò??úforó???μúò????í2?ó??3?μá?--//
for (;c>0;c--)
{
for (b=38*6;b>0;b--)
{
for (a=130;a>0;a--);
}
}
}
/********************************************************************
* ??3? : delay()
* 1|?ü : ?óê±,?óê±ê±???a 100us * t?£?aê?í¨1yèí?t?óê±£?óDò??¨?ó2??£
* ê?è? : t
* ê?3? : ?T
***********************************************************************/
void delay(unsigned int t)
{
unsigned int i,j;
for(i=0; i<t; ?i++)
for(j=0; j<10; j++);
}
void beep()
{
buz=0;
delay10ms(30);
buz=1;
delay10ms(30);
}
void KeyDown(void) ?//êμ?????ó?ü?ì?£·μ???μ?a£??÷°′?üμ??ü?μ£?′??ü?μóéó??§×??o?¨ò??£
{
KeyVal = 99;
num_4x4 = 99;
out_1 = 0;
out_2 = 1;
out_3 = 1;
out_4 = 1;
delay10ms(2);
if(in_1==0)
{
KeyVal = 0;
}
else if(in_2==0)
{
KeyVal = 1;
}
else if(in_3==0)
{
KeyVal = 2;
}
else if(in_4==0)
{
KeyVal = 3;
}
delay10ms(2);
out_1 = 1;
out_2 = 0;
out_3 = 1;
out_4 = 1;
delay10ms(2);
if(in_1==0)
{
KeyVal = 4;
}
else if(in_2==0)
{
KeyVal = 5;
}
else if(in_3==0)
{
KeyVal = 6;
}
else if(in_4==0)
{
KeyVal = 7;
}
delay10ms(2);
out_1 = 1;
out_2 = 1;
out_3 = 0;
out_4 = 1;
delay10ms(2);
if(in_1==0)
{
KeyVal = 8;
}
else if(in_2==0)
{
KeyVal = 9;
}
else if(in_3==0)
{
KeyVal = 10;
}
else if(in_4==0)
{
KeyVal = 11;
}
delay10ms(2);
out_1 = 1;
out_2 = 1;
out_3 = 1;
out_4 = 0;
delay10ms(2);
if(in_1==0)
{
KeyVal = 12;
}
else if(in_2==0)
{
KeyVal = 13;
}
else if(in_3==0)
{
KeyVal = 14;
}
else if(in_4==0)
{
KeyVal = 15;
}
if(KeyVal!=99)
{
beep();
switch(KeyVal)
{
case 0:?? ? num_4x4 = 1;
break;
case 1:?? ? num_4x4 = 4;
break;
case 2:?? ? num_4x4 = 7;
break;
case 3:?? ? num_4x4 = 10;
break;
case 4:?? ? num_4x4 = 2;
break;
case 5:?? ? num_4x4 = 5;
break;
case 6:?? ? num_4x4 = 8;
break;
case 7:?? ? num_4x4 = 0;
break;
case 8:?? ? num_4x4 = 3;
break;
case 9:?? ? num_4x4 = 6;
break;
case 10: num_4x4 = 9;
break;
case 11: num_4x4 = 11;
break;
case 12: num_4x4 = 12;
break;
case 13: num_4x4 = 13;
break;
case 14: num_4x4 = 14;
break;
case 15: num_4x4 = 15;
break;
}
}
//?? ?Lcd1602_Com(0x80);
//?? ?Lcd1602_Data('0'+num_4x4%100/10);
//?? ?Lcd1602_Data('0'+num_4x4%10);
delay10ms(50);
}
需要完整的資料可在我的資源里下載,也可以加入我的紛傳圈子,里面有資源壓縮包的百度網(wǎng)盤(pán)下載地址及提取碼。
紛傳點(diǎn)擊用微信打開(kāi)即可,過(guò)程有點(diǎn)繁瑣請(qǐng)見(jiàn)諒。