功能:
研究内容:本课题以单片机为核心采用C语言来开发一指纹电子密码锁。系统拟在Altium Designer9开发平台上设计原理图,并绘制PCB并制成单片机开发板,然后根据原理图将相关元器件焊接到开发板上。软件部分在Keil uVision4开发平台上进行相关代码的编写和调试。然后利用串口助手工具将代码下载到开发板进行运行,观察硬件各模块是否可以正常运行。以及测试结果是否能够满足需求,便于及时调整设计。
课题的主要任务是设计出一个可以录入指纹,并可对录入指纹进行匹配比较,如果正确即可开锁。
设置有管理员密码,管理员密码内置不可修改,密码具有掉电存储功能。输入管理员密码后进入指纹录制模式,录入自己的指纹录制成功后,支持指纹开锁,指纹匹配成功后,继电器吸合表示开门,并且语音提示开锁成功当遇到震动时,语音提示,请勿强行开锁,并且可以通过sim模块发送报警短信单片机内置用户密码,匹配成功后可以通过app使用密码开锁。重点难点:指纹的录制与识别,语音提示,并且具有报警系统,当遇到震动时时可以发出语音报警和sim短信报警,硬件元器件较多使用了大量串口,pcb排版要注意,避免各个部件之间的干扰。
电路原理图:
资料内容包括:
部分程序:
#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;//½ÓÊÕÊý¾Ý±êÖ¾
unsigned char rec[16]; //½ÓÊÕÊý¾Ý»º´æ
unsigned char recIndex = 0;//½ÓÊÕÊý¾Ý
unsigned char recTemp = 0;//½ÓÊÕÊý¾Ý
char zf[3];
char rec_num = 0; //½ÓÊÕÊý¾Ý¸öÊý
uchar sign = 0;
#define Max_User 10
#define error 2
#define S2RI 0x01 //´®¿Ú2½ÓÊÕÖжÏÇëÇó±ê־λ
#define S2TI 0x02 //´®¿Ú2·¢ËÍÖжÏÇëÇó±ê־λ
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; //½ÓÊÕÊý¾Ý
unsigned char str[3]={0,'\0','\0'};
bit modeflag=0,clearallflag=0,changeflag=0;//ĬÈÏΪʶ±ðģʽ£¬Èç¹ûΪ1Ϊ¼ÈëÖ¸ÎÆģʽ,ÿ¼ÈëÒ»´ÎSaveNumber++
//³£ÓÃÖ¸ÁÒå/
//Verify Password £ºÑéÖ¤É豸ÎÕÊÖ¿ÚÁî
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 £ºÌ½²âÊÖÖ¸²¢´Ó´«¸ÐÆ÷É϶ÁÈëͼÏñ
unsigned char code GIMG[14]={12, 0X01 ,0Xff,0xff,0xff,0xff, 0x01, 0,3,1,0x00,0x05}; //»ØËÍ12¸ö
//Gen Templet1 £º¸ù¾ÝÔʼͼÏñÉú³ÉÖ¸ÎÆÌØÕ÷1
unsigned char code GENT1[14]={13,0X01 ,0Xff,0xff,0xff,0xff,0x01,0,4,2,1,0x00,0x08}; //»ØËÍ12¸ö
//Gen Templet2 £º¸ù¾ÝÔʼͼÏñÉú³ÉÖ¸ÎÆÌØÕ÷2
unsigned char code GENT2[14]={13,0X01 ,0Xff,0xff,0xff,0xff,0x01,0,4,2,2,0x00,0x09}; //»ØËÍ12¸ö
//Search Finger £ºÒÔCharBufferA»òCharBufferBÖеÄÌØÕ÷ÎļþËÑË÷Õû¸ö»ò²¿·ÖÖ¸ÎÆ¿â
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ÖеÄÌØÕ÷ÎļþºÏ²¢Éú³ÉÄ£°å£¬½á¹û´æÓÚModelBuffer¡£
unsigned char code MERG[14]={12, 0X01 ,0Xff,0xff,0xff,0xff, 0x01, 0,3,5 , 0x00,0x09};//»ØËÍ12¸ö
//Store Templet £º½«ModelBufferÖеÄÎļþ´¢´æµ½flashÖ¸ÎÆ¿âÖÐ
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 ;Çå¿ÕÖ¸ÎÆ¿â
unsigned char code DELE_all[12]={12,0X01 ,0Xff,0xff,0xff,0xff, 0x01, 0,3, 0x0d,0x00,0x11};
//³£ÓÃÖ¸ÁÒå-------½áÊø///
//ºê¶¨Òå
#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};
//ºê¶¨Òå------------½áÊø
/*********1ºÁÃëÑÓʱ³ÌÐò**********/
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) //Îó²î 0us
{
unsigned char a, b;
//--cÒѾÔÚ´«µÝ¹ýÀ´µÄʱºòÒѾ¸³ÖµÁË£¬ËùÒÔÔÚforÓï¾äµÚÒ»¾ä¾Í²»Óø³ÖµÁË--//
for (;c>0;c--)
{
for (b=38*6;b>0;b--)
{
for (a=130;a>0;a--);
}
}
}
/********************************************************************
* Ãû³Æ : delay()
* ¹¦ÄÜ : ÑÓʱ,ÑÓʱʱ¼äΪ 100us * t¡£ÕâÊÇͨ¹ýÈí¼þÑÓʱ£¬ÓÐÒ»¶¨Îó²î¡£
* ÊäÈë : 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) //ʵÏÖ¾ØÕó¼üÅÌ¡£·µ»ØֵΪ£¬¸÷°´¼üµÄ¼üÖµ£¬´Ë¼üÖµÓÉÓû§×Ô¼º¶¨Òå¡£
{
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);
}
需要完整的资料可在我的资源里下载,也可以加入我的纷传圈子,里面有资源压缩包的百度网盘下载地址及提取码。
纷传点击用微信打开即可,过程有点繁琐请见谅。