当前位置:网站首页>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);
}
}
}
}
边栏推荐
- Simple solution of small up main lottery in station B
- Mysql
- Mysql database
- Redis cluster creation, capacity expansion and capacity reduction
- [set theory] equivalence relation (concept of equivalence relation | examples of equivalence relation | equivalence relation and closure)
- 深入解析kubernetes controller-runtime
- Derivation of variance iteration formula
- Leetcode solution - 02 Add Two Numbers
- 致即将毕业大学生的一封信
- Push box games C #
猜你喜欢
Push box games C #
Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
Oauth2.0 - using JWT to replace token and JWT content enhancement
[system design] proximity service
轻松上手Fluentd,结合 Rainbond 插件市场,日志收集更快捷
Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"
有意思的鼠標指針交互探究
Svn branch management
Kubernetes notes (I) kubernetes cluster architecture
Kubernetes notes (VIII) kubernetes security
随机推荐
Kubernetes notes (VIII) kubernetes security
Oauth2.0 - user defined mode authorization - SMS verification code login
Judge whether the date time exceeds 31 days
Mysql database binlog log enable record
Mysql database table export and import with binary
Simple understanding of ThreadLocal
Kubernetes notes (VII) kuberetes scheduling
Jackson: what if there is a lack of property- Jackson: What happens if a property is missing?
远端rostopic的本地rviz调用及显示
从小数据量分库分表 MySQL 合并迁移数据到 TiDB
GPS坐标转百度地图坐标的方法
Docker advanced learning (container data volume, MySQL installation, dockerfile)
从小数据量 MySQL 迁移数据到 TiDB
Selenium ide installation recording and local project maintenance
Floating menu operation
【系统设计】邻近服务
表达式的动态解析和计算,Flee用起来真香
Cesium entity (entities) entity deletion method
Exportation et importation de tables de bibliothèque avec binaires MySQL
. Net program configuration file operation (INI, CFG, config)