資源簡介
使用51單片機設置的門禁系統,可以輸入密碼開鎖,可以更改密碼,也可以使用AT24C02存儲密碼,達到斷電保護的功能

代碼片段和文件信息
#include?
#include?
#include?
//#include?“IIC.h“
#include?“matrix_key.h“
#include?“HDG12864F1.h“
#include?“Word_Code.h“
#include?“Rose.h“
sbit?LED?=?P2?^?2;//LED燈引腳定義
sbit?BEEP?=?P2?^?3;//蜂鳴器引腳定義
unsigned?char?Key[]?=?“594200“;//初始密碼
//unsigned?char?Buff[7]?=?“\0\0\0\0\0\0\0“;
unsigned?int?length?=?0;
bit?Key_Flag?=?1;//按鍵按下標志位
bit?Key_Display_Flag?=?0;//密碼是否顯示標志
//void?Write_Address_String(unsigned?char?address?unsigned?char?dat[]);
//void?Read_Address_String(unsigned?char?address?unsigned?char?dat[]);
void?Delay(unsigned?int?z);
void?Display_First();
void?Main_Key_Pro();
void?External_Interrupt_Init();
void?Input_Key(unsigned?char?Input_Buff[]);
void?Alter(unsigned?char?Input_Buff[]);
void?Log(unsigned?char?Key_Buff[]);
bit?Check_Key(unsigned?char?Input_Buff1[]?unsigned?char?Input_buff2[]);
void?main()
{
????LED?=?0;
????BEEP?=?0;
P1?=?0x0F;//0000?1111
????//IIC_Init();
????External_Interrupt_Init();
????HDG12864F1_Init();
????Display_First();
????while(1)
????{
????????P1?=?0x0F;//0000?1111
if(Key_Flag?==?1)
{
Key_Flag?=?0;
Main_Key_Pro();
}
????}
}
void?Delay(unsigned?int?z)
{
unsigned?int?i?j;
for(i?=?z;?i?>?0;?i--)
for(j?=?120;?j?>?0;?j--);
}
void?Display_First()
{
????length?=?sizeof(Welcome)?/?sizeof(Welcome[0]);
????HDG12864F1_Write_Char(4?3?Char_Table[10]);
????HDG12864F1_Write_Char(4?4?Char_Table[10]);
????HDG12864F1_Write_String(2?3?length?Welcome);
????HDG12864F1_Write_Char(4?13?Char_Table[10]);
????HDG12864F1_Write_Char(4?14?Char_Table[10]);
}
void?Main_Key_Pro()
{
switch(Matrix_Key_Scan())
{
case?0x7d://修改
Alter(Key);
break;
case?0x77:
Log(Key);
break;
}
HDG12864F1_Clear();
Display_First();
}
void?External_Interrupt_Init()
{
????EA?=?1;
????EX0?=?1;
????IT0?=?1;
}
void?External_Interrupt_0()interrupt?0
{
????Key_Flag?=?1;
}
void?Input_Key(unsigned?char?Input_Buff[])
{
unsigned?int?i?=?0;//記錄密碼輸入個數
????unsigned?int?j?=?0;
????while(i?7)
????{
????????if(i?6)
????????{
????????????switch(Matrix_Key_Scan())
????????????{
????????????//第一行鍵值碼
????????????case?0xee:
????????????????Input_Buff[i]?=?‘7‘;
????????????????++i;
????????????????break;
????????????case?0xde:
????????????????Input_Buff[i]?=?‘8‘;
????????????????++i;
????????????????break;
????????????case?0xbe:
????????????????Input_Buff[i]?=?‘9‘;
????????????????++i;
????????????????break;
????????????case?0x7e://清除
????????????????i?=?0;
????????????????for(j?=?0;?j?7;?j++)
????????????????{
????????????????????HDG12864F1_Write_Char(5?6?+?j?Char_Table[0]);
????????????????????Input_Buff[j]?=?‘\0‘;
????????????????}
????????????????break;
????????????//第二行鍵值碼
????????????case?0xed:
????????????????Input_Buff[i]?=?‘4‘;
????????????????++i;
????????????????break;
????????????case?0xdd:
????????????????Input_Buff[i]?=?‘5‘;
????????????????++i;
????????????????bre
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????24630??2018-05-30?11:56??20180530115050.bmp
?????文件???????32094??2018-07-08?12:49??Backup?Of?Experiment_7.pdsbak
?????文件????????7559??2018-06-27?19:58??Experiment_7.c
?????文件???????32094??2018-07-08?12:49??Experiment_7.pdsprj
?????文件????????3100??2018-07-08?14:52??Experiment_7.pdsprj.LAPTOP-9QG1FV7R.Yu.workspace
?????文件???????86695??2018-06-27?19:59??Experiment_7.uvgui.Yu
?????文件????????5943??2018-05-10?22:18??Experiment_7.uvopt
?????文件???????13893??2018-05-28?17:10??Experiment_7.uvproj
?????文件????????4874??2018-05-30?12:08??HDG12864F1.h
?????文件????????2234??2018-05-09?10:57??IIC.h
?????文件???????32100??2018-05-28?16:39??Last?Loaded?Experiment_7.pdsbak
?????目錄???????????0??2018-10-08?22:06??Listings\
?????文件???????14767??2018-05-30?12:08??Listings\Experiment_7.lst
?????文件???????29231??2018-05-30?12:08??Listings\Experiment_7.m51
?????文件?????????913??2018-05-06?12:31??matrix_key.h
?????目錄???????????0??2018-10-08?22:06??ob
?????文件???????27876??2018-05-30?12:08??ob
?????文件????????1129??2018-05-30?12:08??ob
?????文件???????21697??2018-05-30?12:08??ob
?????文件??????????97??2018-05-30?12:08??ob
?????文件???????33516??2018-05-30?12:08??ob
?????文件????????6581??2018-05-30?12:07??Rose.h
?????文件???????24841??2018-05-09?08:39??Word_Code.h
- 上一篇:黑白點匹配問題代碼
- 下一篇:鐵塔公司選聘試題綜合版含答案
評論
共有 條評論