#include<reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit rs=P3^5;
sbit lcden=P3^4;
sbit dula=P2^6;
sbit wela=P2^7;
uchar new1,new2,new3,new4;
uchar number[]="1234";
uchar password[]="4321";
uchar cuowu[]="Error";
uchar zhengque[]="right";
uchar kaisuo[]="open";
uchar jinzhi[]="wait a minute";
uchar temp,key,wei,wanbi,allow,times,reset;
void delay(uint i) //延时
{
uint m,n;
for(m=i;m>0;m--)
for(n=114;n>0;n--);
}
void write_com(uchar com) //写指令
{
P0=com;
rs=0;
lcden=1;
delay(10);
lcden=0;
}
void write_dat(uchar dat) //写数据
{
P0=dat;
rs=1;
lcden=1;
delay(10);
lcden=0;
}
void init() //初始化
{
dula=0;
wela=0; //关数码管
write_com(0x38);
write_com(0x0c);
write_com(0x06);
}
void getkey() //矩阵按键
{
{
P3=0xfe;
temp=P3;
基于51单片机的简易4位密码锁(液晶1602显示)
最新推荐文章于 2024-01-11 23:44:51 发布
本文详细介绍了使用51单片机设计并实现一个4位数字密码锁的过程,通过液晶1602模块显示相关信息。文中涉及C语言编程,包括密码输入、比对与错误提示等功能实现。
摘要由CSDN通过智能技术生成