加入星計(jì)劃,您可以享受以下權(quán)益:

  • 創(chuàng)作內(nèi)容快速變現(xiàn)
  • 行業(yè)影響力擴(kuò)散
  • 作品版權(quán)保護(hù)
  • 300W+ 專業(yè)用戶
  • 1.5W+ 優(yōu)質(zhì)創(chuàng)作者
  • 5000+ 長(zhǎng)期合作伙伴
立即加入

基于51單片機(jī)的指紋鎖設(shè)計(jì)

10/22 08:59
1310
服務(wù)支持:
技術(shù)交流群

完成交易后在“購(gòu)買成功”頁面掃碼入群,即可與技術(shù)大咖們分享疑惑和經(jīng)驗(yàn)、收獲成長(zhǎng)和認(rèn)同、領(lǐng)取優(yōu)惠和紅包等。

虛擬商品不可退

當(dāng)前內(nèi)容為數(shù)字版權(quán)作品,購(gòu)買后不支持退換且無法轉(zhuǎn)移使用。

加入交流群
掃碼加入
獲取工程師必備禮包
參與熱點(diǎn)資訊討論
放大
實(shí)物圖
相關(guān)方案
  • 方案介紹
    • 基于51單片機(jī)的指紋鎖系統(tǒng)設(shè)計(jì)
  • 相關(guān)文件
  • 相關(guān)推薦
  • 電子產(chǎn)業(yè)圖譜
申請(qǐng)入駐 產(chǎn)業(yè)圖譜

基于51單片機(jī)的指紋鎖系統(tǒng)設(shè)計(jì)

在現(xiàn)代社會(huì),隨著科技的不斷進(jìn)步,家庭安全變得越來越重要。傳統(tǒng)的機(jī)械鎖由于安全性低,已經(jīng)不能滿足人們對(duì)家庭安全的需求。因此,我們?cè)O(shè)計(jì)了一款基于51單片機(jī)指紋鎖系統(tǒng),該系統(tǒng)結(jié)合了指紋識(shí)別技術(shù)和密碼鎖的工作原理,提供了一種安全可靠、操作便捷的解決方案。
實(shí)物圖:

在這里插入圖片描述

系統(tǒng)概述

本指紋鎖系統(tǒng)以STC89C52單片機(jī)為核心,輔以AS608指紋模塊、L298N電機(jī)驅(qū)動(dòng)芯片、LCD1602顯示屏等模塊。系統(tǒng)通過指紋驗(yàn)證或密碼輸入實(shí)現(xiàn)開鎖功能,具有操作簡(jiǎn)便、安全性高的特點(diǎn)。LCD顯示屏用于顯示系統(tǒng)狀態(tài)和用戶操作指引,而L298N芯片則用于驅(qū)動(dòng)鎖具的機(jī)械部分。

硬件設(shè)計(jì)

51單片機(jī)

51單片機(jī)是整個(gè)系統(tǒng)的核心,負(fù)責(zé)處理所有的邏輯控制和數(shù)據(jù)處理。STC89C52單片機(jī)具有足夠的I/O端口,可以連接多個(gè)外部設(shè)備,同時(shí)具備內(nèi)部Flash存儲(chǔ)器,便于程序的存儲(chǔ)和運(yùn)行。

AS608指紋模塊

在這里插入圖片描述

AS608指紋模塊負(fù)責(zé)指紋的采集和識(shí)別。該模塊通過光學(xué)傳感器捕捉用戶的指紋圖像,并通過內(nèi)置算法進(jìn)行特征提取和比對(duì)。模塊通過串口與單片機(jī)通信,發(fā)送和接收控制指令。

L298N電機(jī)驅(qū)動(dòng)芯片

在這里插入圖片描述

L298N芯片用于驅(qū)動(dòng)鎖具的電機(jī),實(shí)現(xiàn)鎖舌的開啟和關(guān)閉。該芯片可以接收單片機(jī)的控制信號(hào),驅(qū)動(dòng)電機(jī)正轉(zhuǎn)或反轉(zhuǎn),從而控制鎖具的開閉狀態(tài)。

LCD1602顯示屏

LCD1602顯示屏用于顯示系統(tǒng)狀態(tài)和用戶操作指引。它能夠顯示多行文本信息,幫助用戶了解當(dāng)前的操作狀態(tài),如指紋驗(yàn)證成功、密碼輸入錯(cuò)誤等提示信息。

軟件設(shè)計(jì)

軟件部分主要包括指紋模塊的驅(qū)動(dòng)程序、用戶界面的控制程序、密碼管理程序和主控制程序。

指紋模塊驅(qū)動(dòng)程序

//AS608?????£?é
volatile unsigned char AS608_RECEICE_BUFFER[32]; //volatile:?μí3×üê???D?′ó?ü?ù?úμ??ú′??áè?êy?Y£??′ê1?ü?°??μ???á?????′ó??′|?áè?1yêy?Y
//FINGERPRINTí¨D?D-òé?¨ò?
code unsigned char AS608_Get_Device[10] ={0x01,0x00,0x07,0x13,0x00,0x00,0x00,0x00,0x00,0x1b};//?úá??é?¤
code unsigned char AS608_Pack_Head[6] = {0xEF,0x01,0xFF,0xFF,0xFF,0xFF};  //D-òé°üí·
code unsigned char AS608_Get_Img[6] = {0x01,0x00,0x03,0x01,0x00,0x05};    //??μ?????í???
code unsigned char AS608_Get_Templete_Count[6] ={0x01,0x00,0x03,0x1D,0x00,0x21 }; //??μ??£°?×üêy
code unsigned char AS608_Search[11]={0x01,0x00,0x08,0x04,0x01,0x00,0x00,0x03,0xE7,0x00,0xF8}; //???÷???????÷·??§0 - 999,ê1ó?BUFFER1?Dμ?ì??÷?????÷
code unsigned char AS608_Search_0_9[11]={0x01,0x00,0x08,0x04,0x01,0x00,0x00,0x00,0x13,0x00,0x21}; //???÷0-9o?????
code unsigned char AS608_Img_To_Buffer1[7]={0x01,0x00,0x04,0x02,0x01,0x00,0x08}; //??í???·?è?μ?BUFFER1
code unsigned char AS608_Img_To_Buffer2[7]={0x01,0x00,0x04,0x02,0x02,0x00,0x09}; //??í???·?è?μ?BUFFER2
code unsigned char AS608_Reg_Model[6]={0x01,0x00,0x03,0x05,0x00,0x09}; //??BUFFER1?úBUFFER2o?3éì??÷?£°?
code unsigned char AS608_Delete_All_Model[6]={0x01,0x00,0x03,0x0d,0x00,0x11};//é?3y?????£?éà??ùóDμ??£°?
volatile unsigned char  AS608_Save_Finger[9]={0x01,0x00,0x06,0x06,0x01,0x00,0x0B,0x00,0x19};//??BUFFER1?Dμ?ì??÷??′?·?μ????¨μ?????
//code unsigned char AS608_num_of_finger_in_lib1[7]={0x01,0x00,0x04,0x1F,0x00,0x00,0x24};//2é?′?????aμ??üá?
//code unsigned char AS608_num_of_finger_in_lib2[7]={0x01,0x00,0x04,0x1F,0x01,0x00,0x25};
//code unsigned char AS608_num_of_finger_in_lib3[7]={0x01,0x00,0x04,0x1F,0x02,0x00,0x26};
//code unsigned char AS608_num_of_finger_in_lib4[7]={0x01,0x00,0x04,0x1F,0x03,0x00,0x27};

 //·¢?í°üí·
void AS608_Cmd_Send_Pack_Head(void)
{
	int i;	
	for(i=0;i<6;i++) //°üí·
		Uart_Send_Byte(AS608_Pack_Head[i]);   
}
//·¢?í??á?
void AS608_Cmd_Check(void)
{
	int i=0;
	AS608_Cmd_Send_Pack_Head(); //·¢?íí¨D?D-òé°üí·
	for(i=0;i<10;i++)
		Uart_Send_Byte(AS608_Get_Device[i]);
}
//?óê?·′à?êy?Y?o3?
void AS608_Receive_Data(unsigned char ucLength)
{
	unsigned char i;				 
	for (i=0;i<ucLength;i++)
		AS608_RECEICE_BUFFER[i] = Uart_Receive_Byte();
}
//FINGERPRINT_??μ?????í????üá?
void AS608_Cmd_Get_Img(void)
{
    unsigned char i;
    AS608_Cmd_Send_Pack_Head(); //·¢?íí¨D?D-òé°üí·
    for(i=0;i<6;i++) //·¢?í?üá? 0x1d
       Uart_Send_Byte(AS608_Get_Img[i]);
}
//??í???×a??3éì??÷??′?·??úBuffer1?D
void FINGERPRINT_Cmd_Img_To_Buffer1(void)
{
 	unsigned char i;
	AS608_Cmd_Send_Pack_Head(); //·¢?íí¨D?D-òé°üí·      
   	for(i=0;i<7;i++)   //·¢?í?üá? ??í???×a??3é ì??÷?? ′?·??ú CHAR_buffer1
		Uart_Send_Byte(AS608_Img_To_Buffer1[i]);
}
//??í???×a??3éì??÷??′?·??úBuffer2?D
void FINGERPRINT_Cmd_Img_To_Buffer2(void)
{
	unsigned char i;
	AS608_Cmd_Send_Pack_Head(); //·¢?íí¨D?D-òé°üí·
	for(i=0;i<7;i++)   //·¢?í?üá? ??í???×a??3é ì??÷?? ′?·??ú CHAR_buffer1
		Uart_Send_Byte(AS608_Img_To_Buffer2[i]);
}
//???÷è?2?ó??§999??
void AS608_Cmd_Search_Finger(void)
{
	unsigned char i;	   	    
	AS608_Cmd_Send_Pack_Head(); //·¢?íí¨D?D-òé°üí·
	for(i=0;i<11;i++)
		Uart_Send_Byte(AS608_Search[i]);   
}
//×a??3éì??÷??
void AS608_Cmd_Reg_Model(void)
{
	unsigned char i;	   		    
	AS608_Cmd_Send_Pack_Head(); //·¢?íí¨D?D-òé°üí·
	for(i=0;i<6;i++)
		Uart_Send_Byte(AS608_Reg_Model[i]);   
}
//é?3y?????£?éà?μ??ùóD?????£°?
void FINGERPRINT_Cmd_Delete_All_Model(void)
{
	unsigned char i;    
    AS608_Cmd_Send_Pack_Head(); //·¢?íí¨D?D-òé°üí·   
    for(i=0;i<6;i++) //?üá?é?3y?????£°?
      	Uart_Send_Byte(AS608_Delete_All_Model[i]);   
}
//±£′?????
void AS608_Cmd_Save_Finger( unsigned int storeID )
{
	unsigned long temp = 0;
	unsigned char i;
	AS608_Save_Finger[5] =(storeID&0xFF00)>>8;
	AS608_Save_Finger[6] = (storeID&0x00FF);
	for(i=0;i<7;i++)   //????D£?éoí
		temp = temp + AS608_Save_Finger[i]; 
	AS608_Save_Finger[7]=(temp & 0x00FF00) >> 8; //′?·?D£?éêy?Y
	AS608_Save_Finger[8]= temp & 0x0000FF;		   
	AS608_Cmd_Send_Pack_Head(); //·¢?íí¨D?D-òé°üí·	
	for(i=0;i<9;i++)  
		Uart_Send_Byte(AS608_Save_Finger[i]);      //·¢?í?üá? ??í???×a??3é ì??÷?? ′?·??ú CHAR_buffer1
}
//2é?′μ±?°?????a?D?????£°?êy
int AS608_number_of_fingers()
{
 	int num=1;//??è??£°??a?DóDò????£°?
	uchar i=0;
	AS608_Cmd_Send_Pack_Head(); //·¢?íí¨D?D-òé°üí·
	for(i=0;i<6;i++)
	  	Uart_Send_Byte(AS608_Get_Templete_Count[i]);
	AS608_RECEICE_BUFFER[9]=1;//·?±?oóD??D??ê?·??óê?3é1|
	AS608_Receive_Data(14);//?óê?êy?Y
	if(AS608_RECEICE_BUFFER[9]==0) //?óê?3é1|
	 	num=AS608_RECEICE_BUFFER[10]*256+AS608_RECEICE_BUFFER[11];//?′?ó?£°?×ü??êy			
	return num;
}
//áíò???·?·¨2é?′?????a?Dê?·?óD?£°? //±?à′ó|??2é?′?ùóD1000???£°?????ê?·?′??ú?£°?£?μ?ò?°???ó?μ?μ??°256??£?1ê′ó?ò
/*
bit AS608_notEmpty()
{
 	bit exist=0;
	char i=0;
	AS608_Cmd_Send_Pack_Head(); //·¢?íí¨D?D-òé°üí·
	for(i=0;i<7;i++)
	{
		  Uart_Send_Byte(AS608_num_of_finger_in_lib1[i]);
	}
	AS608_Receive_Data(10);//?óê??°10byteêy?Y,3yμú10×??úμ?è·è???ía£???óàè?2??a?ú
	if(AS608_RECEICE_BUFFER[9]==0) //?óê?3é1|
	{
	AS608_Receive_Data(32);//?óê?oóD?32byteêy?Y£?′??′0~255???£°??aê?·?′??ú?????£°?μ?êy?Y
	for(i=0;i<32;i++)//2é?′?a32byteêy?Y£?è?o?ò???????′??ú?£°??ò·μ???μ?a??£?·??ò?a?ù
	{
	 	if(AS608_RECEICE_BUFFER[i])
			exist=1;
	}
	return exist;
	}
}
*/
//ìí?ó????
void AS608_Add_Fingerprint()
{
	unsigned char id_show[]={0,0,0};
	LCD1602_WriteCMD(0x01); //???á  
	while(1)
	{
		LCD1602_Display(0x80,"   Add  finger  ",0,16);
		LCD1602_Display(0xc0,"    ID is       ",0,16);
		//°′·μ???ü?±?ó??μ??÷2?μ¥
		if(KEY_CANCEL == 0) 
		{
		Delay_ms(5);
		if(KEY_CANCEL == 0)
		{
			while(KEY_CANCEL==0);
			break;
		}	 
		}

		//°′?D???ü????iD?μ?ó1
		if(KEY_DOWN == 0)
		{
		Delay_ms(5);
		if(KEY_DOWN == 0)
		{
			while(KEY_DOWN==0);
			if(finger_id == 1000)
				finger_id = 1;//±£á?0o?2?±??2??
			else
				finger_id = finger_id + 1;
		}		
		}

	 	//????iD?μ??ê?′|àí 
	 	LCD1602_WriteCMD(0xc0+10);
	 	LCD1602_Display_Number(finger_id);
	 	//°′è·è??ü?aê???è?????D??¢ 		 			
	 	if(KEY_OK == 0)
	 	{
	 	Delay_ms(5);
	 	if(KEY_OK == 0)
	  	{	
			while(KEY_OK==0);
		  	LCD1602_Display(0x80," Please  finger ",0,16);
		  	LCD1602_Display(0xc0,"                ",0,16);
			while(KEY_CANCEL == 1)
	 		{
		  		//°′??·μ???üí?3???è?·μ??fingerIDμ÷??×′ì?   
				if(KEY_CANCEL == 0) 
			 	{
			 	 Delay_ms(5);
				if(KEY_CANCEL == 0)
				{
					while(KEY_CANCEL==0);
			  		break;
				}
			  	}

				AS608_Cmd_Get_Img(); //??μ?????í???
				AS608_Receive_Data(12);
				//?D???óê?μ?μ?è·è???,μèóú0??????è?3é1|
				if(AS608_RECEICE_BUFFER[9]==0)
			 	{
					Delay_ms(100);
					FINGERPRINT_Cmd_Img_To_Buffer1();
			    	AS608_Receive_Data(12);
					LCD1602_Display(0x80,"Successful entry",0,16);
					Beep_Times(1);
					Delay_ms(1000);
					LCD1602_Display(0x80," Please  finger ",0,16);
		  			LCD1602_Display(0xc0,"                ",0,16);
					while(1)
					{
						if(KEY_CANCEL == 0) 
			 			{
			 	 		Delay_ms(5);
						if(KEY_CANCEL == 0)
						{
							while(KEY_CANCEL==0);
			  				break;
						}
			  			}

				 		AS608_Cmd_Get_Img(); //??μ?????í???
				 		AS608_Receive_Data(12);
						//?D???óê?μ?μ?è·è???,μèóú0??????è?3é1|
						if(AS608_RECEICE_BUFFER[9]==0)
						{
							Delay_ms(200);
							LCD1602_Display(0x80,"Successful entry",0,16);
							LCD1602_Display(0xc0,"    ID is       ",0,16);
						 	//????iD?μ??ê?′|àí 
						 	LCD1602_WriteCMD(0xc0+10);
						 	LCD1602_Display_Number(finger_id);
							FINGERPRINT_Cmd_Img_To_Buffer2();
				  			AS608_Receive_Data(12);
							AS608_Cmd_Reg_Model();//×a??3éì??÷??
         					AS608_Receive_Data(12); 
					  		AS608_Cmd_Save_Finger(finger_id);                		         
          					AS608_Receive_Data(12);
							Beep_Times(1);
							Delay_ms(1000);
							finger_id=finger_id+1;
				    		break;
			  			}
			   		}
				   	break;
				}
			}
		}
		}
	}
}

//???÷????
void AS608_Find_Fingerprint()
{
	unsigned int find_fingerid = 0;
	unsigned char id_show[]={0,0,0};
	do
	{
		LCD1602_Display(0x80," Please  finger ",0,16);
		LCD1602_Display(0xc0,"                ",0,16);
		AS608_Cmd_Get_Img(); //??μ?????í???
		AS608_Receive_Data(12);		
		//?D???óê?μ?μ?è·è???,μèóú0??????è?3é1|
		if(AS608_RECEICE_BUFFER[9]==0)
		{			
			Delay_ms(100);
			FINGERPRINT_Cmd_Img_To_Buffer1();
			AS608_Receive_Data(12);		
			AS608_Cmd_Search_Finger();
			AS608_Receive_Data(16);			
			if(AS608_RECEICE_BUFFER[9] == 0) //???÷μ?  
			{
				//?a??3é1|//
				
				LCD1602_Display(0x80," Search success ",0,16);
				LCD1602_Display(0xc0,"    ID is       ",0,16);
				Beep_Times(1);					
				//?′?ó????IDêy
				find_fingerid = AS608_RECEICE_BUFFER[10]*256 + AS608_RECEICE_BUFFER[11];					
				 //????iD?μ??ê?′|àí 
				 LCD1602_WriteCMD(0xc0+10);
				 LCD1602_Display_Number(find_fingerid);
				//????IO?ú£??′DD?a??2ù×÷
				if(flag)
				{
				P1=0xfe;						
				Delay_ms(OpenTime*100);
				P1=0xff;	//μ??ˉ?úí£?1×a?ˉ
				Delay_ms(1000);
				P1=0xfd;	//μ??ˉ?ú·′×a?′??
				Delay_ms(CloseTime*100);//μ??ú?y×a×èá|??′óóú·′×a£?Dy×a?àí????èê±£??y×aDèòa?ü?àê±??	
				P1=0xff;	//μ??ˉ?úí£?1×a?ˉ
				}
				flag=1;	//?êDíoóD??à1?2ù×÷£oìí?ó?òé?3y?????£°?
				break;							
			}
			else //??óD?òμ?
			{
					LCD1602_Display(0x80," Search  failed ",0,16);
					LCD1602_Display(0xc0,"                ",0,16);
				 	Beep_Times(3);
			}
		}		
	}while(KEY_CANCEL == 1);
}
//é?3y?ùóD′??üμ??????a
void AS608_Delete_All_Fingerprint()
{
		unsigned char i=0;
		LCD1602_Display(0x80,"   empty all    ",0,16);
		LCD1602_Display(0xc0,"   Yes or no ?  ",0,16); 
		do
		 {
			if(KEY_OK==0)
			{
			Delay_ms(5);
			if(KEY_OK==0)
			{
				while(KEY_OK==0);
				LCD1602_Display(0x80,"   emptying     ",0,16);
				LCD1602_Display(0xc0,"                ",0,16); 
				Delay_ms(300);
				LCD1602_WriteCMD(0xc0);
				for(i=0;i<16;i++)
				 {
					LCD1602_WriteDAT(42);// ?′'*'
					Delay_ms(100);
				 }
				FINGERPRINT_Cmd_Delete_All_Model();
			  	AS608_Receive_Data(12); 
				LCD1602_Display(0x80,"   All empty    ",0,16);
				LCD1602_Display(0xc0,"                ",0,16);
				Beep_Times(3);
				break;
			}
			}
		 }while(KEY_CANCEL==1);
}

該程序負(fù)責(zé)與AS608指紋模塊進(jìn)行通信,實(shí)現(xiàn)指紋的采集、特征提取和比對(duì)。程序通過串口發(fā)送指令,控制指紋模塊的工作狀態(tài),并接收模塊返回的比對(duì)結(jié)果。

用戶界面控制程序

//òo?§·±?|?ì2a
void LCD1602_CheckBusy(void)
{
	
	uchar busy;
	DataPort=0xff; 
	RS=0;
	RW=1;
	do
	{
		EN=1;
		busy=DataPort;
		EN=0;
	}while(busy&0x80);	
}
//òo?§3?ê??ˉoˉêy
void LCD1602_Init(void)  
{
	Delay_ms(15);      		//é?μ??óê±15ms
  	LCD1602_WriteCMD(0x38); //D′??ê???á?(2??ì2a?|D?o?)
  	Delay_ms(5);
  	LCD1602_CheckBusy();
  	LCD1602_WriteCMD(0x38); //D′??ê???á?
  	LCD1602_CheckBusy();
  	LCD1602_WriteCMD(0x01); //???á
  	LCD1602_CheckBusy();
  	LCD1602_WriteCMD(0x06); //??ê?1a±êò??ˉéè??
  	LCD1602_CheckBusy();
  	LCD1602_WriteCMD(0x0c); //??ê??a?°1a±êéè??  
}
//òo?§??ê?oˉêy		è??ú2?êy£oaddr?eê?μ??·£?pointer????μ??·£?index??±ê£?num??êy
void LCD1602_Display(unsigned char addr,unsigned char* pointer,unsigned char index,unsigned char num)
{
  	unsigned char i;
  	LCD1602_CheckBusy();	//?D???|D?o?
  	LCD1602_WriteCMD(addr);	//D′è?μ??·
  	for(i=0;i<num;i++)		//D′è?êy?Y
  	{
     	LCD1602_CheckBusy();			   //?D???|D?o?
     	LCD1602_WriteDAT(pointer[index+i]);//D′è?êy?Y     
  	}
}
//òo?§??ê?????êy
void LCD1602_Display_Number(unsigned int num)
{
	if(num/1000)
		LCD1602_WriteDAT(num/1000+48);	
	LCD1602_WriteDAT(num%1000/100+48);
	LCD1602_WriteDAT(num%100/10+48);
	LCD1602_WriteDAT(num%10+48);
}

該程序負(fù)責(zé)控制LCD1602顯示屏,顯示系統(tǒng)狀態(tài)和用戶操作指引。程序根據(jù)系統(tǒng)的工作狀態(tài),動(dòng)態(tài)更新顯示內(nèi)容,提供清晰的用戶交互界面。

主控制程序

//?÷oˉêy
void main()
{							
	finger_id=0;
	I2C_init();//I2C3?ê??ˉ
	LCD1602_Init();			//3?ê??ˉòo?§
	LCD1602_Display(0x80," Designer : lsy ",0,16);	 //òo?§?a?ú??ê?????
	Delay_ms(500);	
	LCD1602_Display(0x80,"Fingerprint Test",0,16);	 //òo?§?a?ú??ê?????
  	Uart_Init();			//3?ê??ˉ′??ú
	Key_Init();				//3?ê??ˉ°′?ü
 	Delay_ms(200);          //?óê±200MS£?μè′y?????£?é?′??
	Device_Check();		   	//D£???????£?éê?·??óè??yè·£?òo?§×?3??àó|μ?ìáê?
	Delay_ms(1000);			//???ó3é1|????í£á?ò??¨ê±??
	OpenTime=I2C_ReadData(254);//′óAT24C02μú254??μ¥?a?D?áè?êy?Y
	CloseTime=I2C_ReadData(250);//′óAT24C02μú255??μ¥?a?D?áè?êy?Y
	while(1)
	{
	    
		/**************??è??÷1|?ü????****************/
		LCD1602_Display(0x80,"  search finger ",0,16);	 //μúò?????ê????÷????
		LCD1602_Display(0xc0,"  Add     delete",0,16);	 //ìí?óoíé?3y????
		switch(local_date)
		{
			case 0:
				LCD1602_Display(0x80,  " *",0,2);
				LCD1602_Display(0xc0,  "  ",0,2);
				LCD1602_Display(0xc0+8,"  ",0,2);
			break;
			case 1:
				LCD1602_Display(0x80,  "  ",0,2);
				LCD1602_Display(0xc0,  " *",0,2);
				LCD1602_Display(0xc0+8,"  ",0,2);
			break;
			case 2:
				LCD1602_Display(0x80,  "  ",0,2);
				LCD1602_Display(0xc0,  "  ",0,2);
				LCD1602_Display(0xc0+8," *",0,2);
			break;	
		}

		//è·è??ü
		if(KEY_OK == 0)
		{
		Delay_ms(5);
		if(KEY_OK == 0)
		{	 
		 	while(KEY_OK == 0);//μè′y?é?a°′?ü								
			switch(local_date)
			{
				case 0:  //???÷????	
					flag=1;					
					AS608_Find_Fingerprint();																								
					break;		
				case 1:	 //ìí?ó????
					flag=1;	//flag=1£?è??????a?a??£??ò?éò??±?óìí?ó????				
					if(AS608_number_of_fingers())
					{
						flag=0;//flag??0óéá???×÷ó?£o
						//1?¢?????a?Dò?óD????£??òDèòa???÷?¥??3é1|£?óéAS608_Find_Fingerprint()??flag??1£?2??üìí?ó????
						//2?¢flag=0£??ò?ú???÷????3é1|oó2??′DD?a??2ù×÷
						AS608_Find_Fingerprint();
					}
					if(flag)
						AS608_Add_Fingerprint();
					break; 					
				case 2:	//????????
					flag=0;	//1?¢?ú???÷????3é1|oó2??′DD?a??2ù×÷£?2?¢è????÷2?3é1|£?2??′DD????2ù×÷
					AS608_Find_Fingerprint();//???÷?¥??3é1|oó£?oˉêy?ú2???flag??1£?2??ü?????????a
					if(flag)
						AS608_Delete_All_Fingerprint();
					break;
			}
		}
		}
		//?D???ü
		if(KEY_DOWN == 0)
		{
		Delay_ms(5);
		if(KEY_DOWN == 0)
		{
		 	while(KEY_DOWN == 0); //μè′y?é?a°′?ü
		 	local_date++;
		 	if(local_date==3) 
		 		local_date=0;	
		}
		}

		//°′Key_Mode??è?ê±??μ÷???£ê?
		if (KEY_Mode == 0)
		{
		Delay_ms(5);
		if(KEY_Mode == 0)
		{
			while(KEY_Mode == 0);
			flag=0;
			AS608_Find_Fingerprint();
			if(flag)
				Refresh_time();
		}
		}						
		
		Delay_ms(100); //?óê±?D??100MS?ì2aò?′?		
	}
}

主控制程序負(fù)責(zé)協(xié)調(diào)各個(gè)模塊的工作,實(shí)現(xiàn)系統(tǒng)的開鎖邏輯。當(dāng)用戶進(jìn)行指紋驗(yàn)證或密碼輸入時(shí),主程序會(huì)調(diào)用相應(yīng)的驅(qū)動(dòng)程序,根據(jù)驗(yàn)證結(jié)果控制L298N芯片,實(shí)現(xiàn)鎖具的開閉。

系統(tǒng)功能

本指紋鎖系統(tǒng)具備以下功能:

  1. 指紋開鎖:用戶可以通過驗(yàn)證指紋來開鎖。
  2. 狀態(tài)顯示:LCD顯示屏?xí)?shí)時(shí)顯示系統(tǒng)狀態(tài),如開鎖成功、密碼錯(cuò)誤等。
  3. 安全報(bào)警:如果連續(xù)多次輸入錯(cuò)誤的指紋,系統(tǒng)會(huì)觸發(fā)報(bào)警。

結(jié)論

基于51單片機(jī)的指紋鎖系統(tǒng)設(shè)計(jì),不僅提高了家庭安全的水平,也為用戶提供了便捷的開鎖方式。通過結(jié)合現(xiàn)代電子技術(shù)和生物識(shí)別技術(shù),該系統(tǒng)在保證安全性的同時(shí),也提供了良好的用戶體驗(yàn)。隨著技術(shù)的不斷進(jìn)步,未來指紋鎖系統(tǒng)將更加智能化、多樣化,為家庭安全提供更加可靠的保障。

原理圖

在這里插入圖片描述
PCB設(shè)計(jì)
在這里插入圖片描述

希望你喜歡這個(gè)項(xiàng)目,并在構(gòu)建過程中找到樂趣!如果你有任何問題或需要幫助,歡迎在評(píng)論區(qū)交流。

作者:Svan.


注意:本博文為不得在未經(jīng)本人同意進(jìn)行轉(zhuǎn)載或者二次創(chuàng)作,違者必究?。?!

博客主頁:https://blog.csdn.net/weixin_51141489,需要源碼或相關(guān)資料實(shí)物的友友請(qǐng)關(guān)注、點(diǎn)贊,私信吧!

  • 聯(lián)系方式.txt

相關(guān)推薦

電子產(chǎn)業(yè)圖譜