AT89C52单片机+AT24C02+1602构成的密码锁
#include
#include
#include
#define uchar unsigned char
#define uint unsigned int
uchar code table[]="Input Password:
uchar code table1[]="
uchar code table2[]="You are welcome!";
uint
uint
sbit lcdrs=P2^0;
sbit lcdrw=P2^1;
sbit lcden=P2^2;
sbit led=P2^5;
sbit fmq=P2^4;
sbit jdq=P2^3;
sbit key=P2^6;
uint x;
uint num,temp;
uint keyscan();
void delay_50us(uint t)
{
uint y;
for(;t>0;t--)
for(y=19;y>0;y--);
}
void delay_1ms(uint z)
{
uint x,y;
for(x=z;x>0;x--)
for(y=110;y>0;y--);
}
void delay(void)
{
}
void delay1ms()
{
}
void write_com(uchar com)
{
lcdrs=0;
lcdrw=0;
lcden=0;
P0=com;
delay_50us(10);
lcden=1;
delay_50us(20);
lcden=0;
}
void write_data(uchar date)
{
lcden=0;
lcdrs=1;
lcdrw=0;
P0=date;
delay_50us(10);
lcden=1;
delay_50us(20);
lcden=0;
}
void init()
{
write_com(0x38);
delay_50us(100);
delay_50us(100);
write_com(0x06);
delay_50us(100);
delay_50us(100);
}
void main()
{
uint a=0,q=0,d=0,jiesu;
uint b=0;
uint kai;
delay_50us(300);
init();
fmq=1;
write_com(0x80);
for(x=0;x<16;x++)
{
write_data(table[x]);
delay_50us(100);
write_com(0x80+0x44);
while(1)
if(keyscan()!=0)
{
mima[a++]=kai;
write_com(0x80+0x44+b);
num=0;
b++;
if(b>7&&kai!=0x7f)
{
{
write_data(table1[x]);
delay_50us(100);
delay_1ms(700);
}
else if(kai==0x7f&&b<=7)
{
{
write_data(table1[x]);
delay_50us(100);
delay_1ms(700);
}
else
{
}
q++;
if(d==6)
{
write_com(0x80);
for(x=0;x<16;x++)
write_data(table2[x]);
delay_50us(100);
jdq=0;
delay_1ms(500);
fmq=1;
led=0;
break;
}
else
{
write_data(table1[x]);
delay_50us(100);
}
}
}
else if(kai==0x7e)
{
break;
}
}
}
}
uint keyscan()
{
P1=0xef;
temp=P1;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P1;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P1;
switch(temp)
{
case 0xee:num=0x31;
case 0xed:num=0x34;
case 0xeb:num=0x37;
case 0xe7:num=0x7f;
default:num=0;
}
while(temp!=0x0f)
{
temp=P1;
temp=temp&0x0f;
}
}
}
P1=0xdf;
temp=P1;
temp=temp&0x0f;
while(temp!=0x0f)
{
delay_1ms(5);
temp=P1;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P1;
switch(temp)
{
case 0xde:num=0x32;
case 0xdd:num=0x35;
case 0xdb:num=0x38;
case 0xd7:num=0x30;
default:num=0;
}
while(temp!=0x0f)
{
temp=P1;
temp=temp&0x0f;
}
}
}
P1=0xbf;
temp=P1;
temp=temp&0x0f;
while(temp!=0x0f)
{
delay_1ms(5);
temp=P1;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P1;
switch(temp)
{
case 0xbe:num=0x33;
case 0xbd:num=0x36;
case 0xbb:num=0x39;
case 0xb7:num=0x7e;
default:num=0;
}
while(temp!=0x0f)
{
temp=P1;
temp=temp&0x0f;//http://www.5imcu.net/
}
}
}
P1=0x7f;
temp=P1;
temp=temp&0x0f;
while(temp!=0x0f)
{
delay_1ms(5);
temp=P1;
temp=temp&0x0f;
while(temp!=0x0f)
{
temp=P1;
switch(temp)
{
case 0x7e:num=0x41;
case 0x7d:num=0x42;
case 0x7b:num=0x43;
case 0x77:num=0x44;
}
while(temp!=0x0f)
{
temp=P1;
temp=temp&0x0f;
}
}
}
}
AT89C52单片机AT24C021602密码 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)