单片机电子密码锁子程序
仿真文件和完整源码下载地址:http://www.51hei.com/bbs/dpj-22586-1.html
论文下载地址:http://www.51hei.com/f/电子密码锁论文最终稿.docx
下面是mima.c子程序:
#include
#include "mima.h"
#include "1602.h"
#include "adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=17&is_app=0&jk=43258ce73f1bca35&k=%BE%D8%D5%F3&k0=%BE%D8%D5%F3&kdi0=0&luki=1&n=10&p=baidu&q=98059059_cpr&rb=0&rs=1&seller_id=1&sid=35ca1b3fe78c2543&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1831118&u=http%3A%2F%2Fwww%2E51hei%2Ecom%2Fmcu%2F2085%2Ehtml&urlid=0" id="5_nwl" mpid="5" target="_blank">矩阵键盘.h"
#include "delay_ms.h"
/*比较密码函数,密码正确返回1,不正确返回0*/
bitmimaduibi(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*/
bitinput_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
}
}
if(key == enter)//没完成密码输入返回错误信息
{
lcd_pos(0,0);
return(0);
}
}
if(count==6)
{
do{key = keyscan();}
while((key != backspace)&&(key != enter));
if(key == backspace)
{
lcd_pos(1,--count);
write_data( );
mima[count]= ;
lcd_pos(1,count);
count--;
}
if(key == enter)//密码位数正确
{
return(1);//返回1正确信号
}
}
}
}
单片机电子密码 相关文章:
- 单片机电子密码锁程序(2)(11-30)
- 一种简单51单片机电子密码锁设计(11-21)
- 单片机实现电子密码锁(11-18)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)