当前位置:网站首页>Simple password lock
Simple password lock
2022-07-03 06:23:00 【Bitongo】
This section simulates the smart door lock , be based on 51 The four digit simple password lock made under the single chip microcomputer
The modules used are LCD1602 LCD screen ( Used to display the entered password ) and Matrix key ( Used to enter a password )
The specific code is as follows :
LCD1602 Previously described in detail , Only the functions that need to be used are listed here , For details, please click “ LCD1602 Liquid crystal display (LCD) ”
LCD1602.c
/** * @brief stay LCD1602 Start displaying the given number at the specified position * @param Line Start line position , Range :1~2 * @param Column Start column position , Range :1~16 * @param Number Number to display , Range :0~65535 * @param Length The length of the number to display , Range :1~5 * @retval nothing */
void LCD_ShowNum(unsigned char Line,unsigned char Column,unsigned int Number,unsigned char Length)
{
unsigned char i;
LCD_SetCursor(Line,Column);
for(i=Length;i>0;i--)
{
LCD_WriteData(Number/LCD_Pow(10,i-1)%10+'0');
}
}
/** * @brief stay LCD1602 Start displaying the given string at the specified position * @param Line Start line position , Range :1~2 * @param Column Start column position , Range :1~16 * @param String String to display * @retval nothing */
void LCD_ShowString(unsigned char Line,unsigned char Column,char *String)
{
unsigned char i;
LCD_SetCursor(Line,Column);
for(i=0;String[i]!='\0';i++)
{
LCD_WriteData(String[i]);
}
}
Matrixkey.c
unsigned char MatrixKey()
{
key=0x0f;
if(key!=0x0f)
{
Delay(100);
if(key!=0x0f)
{
key=0x0f;
switch(key)
{
case 0x07 : keyvalue=1;break;
case 0x0b : keyvalue=2;break;
case 0x0d : keyvalue=3;break;
case 0x0e : keyvalue=4;break;
}
key=0xf0;
switch(key)
{
case 0x70 : keyvalue=keyvalue;break;
case 0xb0 : keyvalue=keyvalue+4;break;
case 0xd0 : keyvalue=keyvalue+8;break;
case 0xe0 : keyvalue=keyvalue+12;break;
}
return keyvalue;
}
}
}
main.c
void main()
{
LCD_Init(); //LCD initialization
LCD_ShowString(1,1,"Input Keys :"); //LCD display string
while(1)
{
t=MatrixKey(); // Get matrix keyboard key code
if(t) // If a key is pressed
{
if(t<=10)
{
if(cot<4)
{
keys=keys*10;
keys=keys+t%10;
cot++;
}
LCD_ShowNum(2,1,keys,4);//LCD Display password
}
if(t==11)
{
if(keys==1102)
{
LCD_ShowString(1,14,"OK ");
keys=0;
cot=0;
LCD_ShowNum(2,1,keys,4);//LCD Display password
}
else
{
LCD_ShowString(1,14,"ERR");
keys=0;
cot=0;
LCD_ShowNum(2,1,keys,4);//LCD Display password
}
}
if(t==12)
{
keys=0;
cot=0;
LCD_ShowNum(2,1,keys,4);
}
}
}
}
边栏推荐
- 有意思的鼠标指针交互探究
- 轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
- 技术管理进阶——你了解成长的全貌吗?
- Get a screenshot of a uiscrollview, including off screen parts
- Kubernetes notes (II) pod usage notes
- opencv鼠标键盘事件
- Migrate data from Amazon aurora to tidb
- Zhiniu stock project -- 05
- 【LeetCode】Day93-两个数组的交集 II
- Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)
猜你喜欢

Cesium 点击获三维坐标(经纬度高程)

scroll-view指定滚动元素的起始位置

Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface

CKA certification notes - CKA certification experience post

Mysql

Use abp Zero builds a third-party login module (I): Principles

从小数据量分库分表 MySQL 合并迁移数据到 TiDB

ssh链接远程服务器 及 远程图形化界面的本地显示

Zhiniu stock project -- 04

Oauth2.0 - using JWT to replace token and JWT content enhancement
随机推荐
Kubernetes notes (VI) kubernetes storage
Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
远端rostopic的本地rviz调用及显示
剖析虚幻渲染体系(16)- 图形驱动的秘密
SQL实现将多行记录合并成一行
Exportation et importation de tables de bibliothèque avec binaires MySQL
Kubernetes notes (VII) kuberetes scheduling
Learning notes -- principles and comparison of k-d tree and IKD tree
Selenium - 改变窗口大小,不同机型呈现的宽高长度会不一样
JMeter linked database
Kubernetes notes (IV) kubernetes network
Various usages of MySQL backup database to create table select and how many days are left
【LeetCode】Day93-两个数组的交集 II
Leetcode solution - 01 Two Sum
Printer related problem record
Scripy learning
pytorch练习小项目
Mysql database binlog log enable record
第8章、MapReduce 生产经验
“我为开源打榜狂”第一周榜单公布,160位开发者上榜