210 基于51单片机的智能门禁系统仿真设计

更改密码时,需要首先拿下修改密码键,然后输入原始密码,再输两次新密码即可修改成功。
刷门禁卡由按键开关代替,存储功能实现了的。

完整版 电路图和程序代码 下载地址

https://pan.baidu.com/s/1igt3r0Eba80R-jbnVgd78Q?pwd=8888

部分代码展示

#include <reg52.h>
#include "mima.h"
#include "1602.h"
#include "矩阵键盘.h"
#include "delay_ms.h"

/*比较密码函数,密码正确返回1,不正确返回0*/

bit mimaduibi(unsigned char *string1,unsigned char *string2)
{
	unsigned char count;
	for(count = 0; count < 6; count++)
	{
		if(string1[count] != string2[count])
		return 0;
	}
	return 1;
}

/*选择输入密码或修改密码函数,输入密码返回A,修改密码返回B*/

unsigned char step_choose(void)//选择输入密码或修改密码处理函数
{
	uchar key;
	key = 0xff;
	write_com(0x06);//写一个字符后地址指针加 1 
    write_com(0x01);//显示清零,数据指针清零
	lcd_pos(0,0);
	write_n_char(" Input password ");
	lcd_pos(1,0);
	write_n_char("  Press key A  ");	
	while((key != A) && (key != B))
		key = keyscan();	
	return key;
}
/*输入密码函数,密码正确返回1,错误返回0*/

bit input_mima(uchar * mima)//输入密码函数
{
	unsigned char count,key;
	lcd_pos(1,0);
	for(count = 0; count < 7; count++)
	{
		delay_ms(100);
		if(count < 6)
		{
			do{key = keyscan();}//扫描键盘
			while(key == 0xff);
			if((key != backspace) && (key != A) && (key != enter))//不是退格也不是确认键
			{
				write_data('*');//是数字键显示*
				mima[count] = key;
			//	continue;
			}
			if(key == backspace)//是退格键
			{
				if(count > 0)
				{
				    lcd_pos(1,--count);//光标前移一位
					write_data(' ');//清空一位
					mima[count] = ' ';//写空
					lcd_pos(1,count);
					count--;//密码计数器减一 ,因为循环后会+1,所以在这里要加1
				}
			}

  • 16
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值