note4微信小程序禁止下滑打字下滑线能换颜色吗

矩阵键盘密码锁
单片机&嵌入式
单片机应用
嵌入式操作系统
学习工具&教程
学习和开发单片机的必备工具
(有问必答)
(带你轻松入门)
电子元件&电路模块
当前位置: >>
>> 浏览文章
矩阵键盘密码锁
#include&reg52.h>
#include&intrins.h>
#define uint unsigned int
#define uchar unsigned char
#define ulong unsigned long
//这三个引脚参考资料
sbit E=P2^7; //1602使能引脚
sbit RW=P2^6; //1602读写引脚
sbit RS=P2^5; //1602数据/命令选择引脚
void Delay_1ms(uint i)
for(j=0;j&i;j++)
for(x=0;x&=148;x++);
void delay()
bit Busy(void)//状态判断
bit busy_flag = 0;
busy_flag = (bit)(P0 & 0x80);
return busy_
void wcmd(uchar del) // 功能 : 1602命令函数
while(Busy());
void wdata(uchar del) //功能 : 1602写数据函数
while(Busy());
void L1602_init(void) // 功能 : 1602初始化
wcmd(0x38);
Delay_1ms(5);
wcmd(0x38);
Delay_1ms(5);
wcmd(0x38);
Delay_1ms(5);
wcmd(0x38);
wcmd(0x08);
wcmd(0x0c);
wcmd(0x04);
wcmd(0x01);
void L1602_char(uchar hang,uchar lie,char sign)
if(hang == 1) a = 0x80;
if(hang == 2) a = 0xc0;
a = a + lie - 1;
wdata(sign);
void L1602_string(uchar hang,uchar lie,uchar *p)
uchar a,b=0;
if(hang == 1)
if(hang == 2)
a = a + lie - 1;
wcmd(a++);
if((*p == '\0')||(b==16))
wdata(*p);
uchar Keyscan()
uchar num,
temp=temp&0xf0;
while(temp!=0xf0)
temp=temp&0xf0;
while(temp!=0xf0)
switch(temp)
case 0xee:num=0;
case 0xde:num=1;
case 0xbe:num=2;
case 0x7e:num=3;
while(temp!=0xf0)
temp=temp&0xf0;
temp=temp&0xf0;
while(temp!=0xf0)
temp=temp&0xf0;
while(temp!=0xf0)
switch(temp)
case 0xed:num=4;
case 0xdd:num=5;
case 0xbd:num=6;
case 0x7d:num=7;
while(temp!=0xf0)
temp=temp&0xf0;
temp=temp&0xf0;
while(temp!=0xf0)
temp=temp&0xf0;
while(temp!=0xf0)
switch(temp)
case 0xeb:num=8;
case 0xdb:num=9;
case 0xbb:num=10;
case 0x7b:num=11;
while(temp!=0xf0)
temp=temp&0xf0;
temp=temp&0xf0;
while(temp!=0xf0)
temp=temp&0xf0;
while(temp!=0xf0)
switch(temp)
case 0xe7:num=12;
case 0xd7:num=13;
case 0xb7:num=14;
case 0x77:num=15;
while(temp!=0xf0)
temp=temp&0xf0;
void Main(void)
uchar i=6,j=0;
uchar SLED[6]={0}; //读出的键值
ulong Key_V
ulong code6wei = 0x123456; //16进制6位数
ulong codebijiao = 0;
L1602_init();
L1602_string(1,1," The code is:");
Key_Value=10;
Key_Value = Keyscan();
if(Key_Value & 10)
L1602_char(2,i,Key_Value + 48);
L1602_char(2,i,Key_Value + 87);
codebijiao = codebijiao | (Key_Value &&((5-j)*4));
Delay_1ms(300);
if(codebijiao == code6wei)
wcmd(0x01);
L1602_string(1,1,"right!!!");
L1602_string(2,1,"welcome back!!!");
wcmd(0x01);
L1602_string(1,1,"wrong!!!");
L1602_string(2,1,"Input afresh!!!");
Delay_1ms(2000);
wcmd(0x01);
L1602_string(1,1," The code is:");
【】【】【】【】
上一篇:下一篇:
CopyRight @
单片机教程网
, All Rights Reserved

我要回帖

更多关于 微信公众号下滑 的文章

 

随机推荐