当前位置:网站首页>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);
}
}
}
}
边栏推荐
- Difference between shortest path and minimum spanning tree
- conda和pip的区别
- Kubernetes notes (IX) kubernetes application encapsulation and expansion
- Decision tree of machine learning
- How to scan when Canon c3120l is a network shared printer
- Some thoughts on machine learning
- Push box games C #
- MySQL帶二進制的庫錶導出導入
- The mechanical hard disk is connected to the computer through USB and cannot be displayed
- Kubernetes notes (I) kubernetes cluster architecture
猜你喜欢

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

第8章、MapReduce 生产经验

Use selenium to climb the annual box office of Yien

Time format record

Creating postgre enterprise database by ArcGIS

Selenium - 改变窗口大小,不同机型呈现的宽高长度会不一样

輕松上手Fluentd,結合 Rainbond 插件市場,日志收集更快捷

Zhiniu stock project -- 04

使用conda创建自己的深度学习环境

Docker advanced learning (container data volume, MySQL installation, dockerfile)
随机推荐
What's the difference between using the Service Worker Cache API and regular browser cache?
堆排序和优先队列
Example of joint use of ros+pytoch (semantic segmentation)
Kubernetes notes (VIII) kubernetes security
Oauth2.0 - explanation of simplified mode, password mode and client mode
Kubernetes notes (I) kubernetes cluster architecture
Project summary --04
Cesium 点击获三维坐标(经纬度高程)
方差迭代公式推导
Svn branch management
ssh链接远程服务器 及 远程图形化界面的本地显示
远端rostopic的本地rviz调用及显示
Leetcode solution - 02 Add Two Numbers
YOLOV3学习笔记
Click cesium to obtain three-dimensional coordinates (longitude, latitude and elevation)
Print time Hahahahahaha
Zhiniu stock project -- 04
tabbar的设置
Selenium ide installation recording and local project maintenance
YOLOV2学习与总结