当前位置:网站首页>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);
}
}
}
}
边栏推荐
- Local rviz call and display of remote rostopic
- Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
- How matlab modifies default settings
- Project summary --2 (basic use of jsup)
- Leetcode problem solving summary, constantly updating!
- . Net program configuration file operation (INI, CFG, config)
- 简易密码锁
- Simple understanding of ThreadLocal
- Tabbar settings
- 远端rostopic的本地rviz调用及显示
猜你喜欢

Simple understanding of ThreadLocal

【开源项目推荐-ColugoMum】这群本科生基于国产深度学习框架PaddlePadddle开源了零售行业解决方案

“我为开源打榜狂”第一周榜单公布,160位开发者上榜

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

10万奖金被瓜分,快来认识这位上榜者里的“乘风破浪的姐姐”

从小数据量 MySQL 迁移数据到 TiDB

The most responsible command line beautification tutorial

第8章、MapReduce 生产经验

表达式的动态解析和计算,Flee用起来真香

Kubernetes notes (IV) kubernetes network
随机推荐
arcgis创建postgre企业级数据库
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
Cesium 点击获取模型表面经纬度高程坐标(三维坐标)
ssh链接远程服务器 及 远程图形化界面的本地显示
Oauth2.0 - explanation of simplified mode, password mode and client mode
【C#/VB.NET】 将PDF转为SVG/Image, SVG/Image转PDF
Kubernetes notes (III) controller
Get a screenshot of a uiscrollview, including off screen parts
PHP用ENV获取文件参数的时候拿到的是字符串
代码管理工具
UNI-APP中条件注释 实现跨段兼容、导航跳转 和 传参、组件创建使用和生命周期函数
Leetcode solution - 01 Two Sum
Time format record
Naive Bayes in machine learning
Svn branch management
Leetcode solution - 02 Add Two Numbers
Virtual memory technology sharing
MySQL帶二進制的庫錶導出導入
Une exploration intéressante de l'interaction souris - pointeur
【无标题】8 简易版通讯录