基于单片机的电子密码锁1602液晶显示设计

文末下载完整资料

仿真

在这里插入图片描述

程序

//×÷ÕßQQ:497259320
//ÍøÕ¾http://proteus.5d6d.com
//ÄÏÑôÀí¹¤Ñ§Ôº
//ѧϰÊÇÒÅÍüµÄ×îºÃµÄ·½Ê½
//Ö»»¨Á˺ÜÉÙʱ¼äдµÄ,Óкܶ಻×ãµÄËã·¨Óë±à³ÌÐò·½Ê½,¼ûÁÂ!
#include"at89x51.h"
#include"key.h"
#include"lcd.h"
uchar code show_0[]="Please input the password:";
uchar code show_1[]="The cipher is:" ;
uchar code show_2[]="********";
uchar code show_3[]="The password is wrong!";
uchar code show_4[]="This is the last time,";
uchar code show_5[]="Please try it tomorrow!";
uchar code show_6[]="you are right!";
uchar code show_7[]="Please input the new cipher:";
uchar code show_8[]="Input it again!";
uchar code show_9[]="Establishes successful! ";
uchar code show_10[]="(^_^)";
uchar  init_pswd[]={8,8,8,8,8,8,8,8};
uchar  pswd[8]={0};
uchar  pswd_1[8]={0};
void play(uchar *j,uchar k)	  //KÊÇÏÔʾµÄ¸öÊý,jÊǵØÖ·
{
   uchar  i;
   for(i=0;i<k;i++)
   {
    dat_w(*(j+i));
	delay(20);
   }
}
main()
{
  uchar j=0,i=0,sum_1=0;
  loop:init();
  clear();
  gotoxy(1,0);
  play(show_0,16);
  gotoxy(2,0);
  play(show_0+17,10);
  /****ÃÜÂëÊäÈë****/
  do
  {
    key();
  }
  while(ki!=15);
  clear();
  gotoxy(1,0);
  play(show_1,15);
  do
  {
    flag=0;
    key();
	gotoxy(2,0);
	if(flag==1&&ki<=9)
	 {
	  pswd[i]=ki;
	  play(show_2,i);
	  i++;
	 }
	if(ki==14)	//14ÔòÍ˳ö.
	  break;
   }	
   while(i<=8);
   for(i=0;i<=7;i++)
   {
     sum_1=init_pswd[i]-pswd[i]+sum_1;
     if(sum_1!=0)
	 {
	   clear();
	   j++;
	   if(j==3)
	   {
	    clear();
	    gotoxy(1,0);
	    play(show_4,16);
		gotoxy(2,0);
		play(show_4+16,14);
		delay(500);
		delay(500);
		clear();
		gotoxy(1,0);
		play(show_5+7,16);
		gotoxy(2,5);
		play(show_10,5);
	    while(1);   //Èý´ÎÊäÈëÃÜÂëʧ°Ü,×ÔËø
	   }
	   gotoxy(1,0);
	   play(show_3,16);
	   gotoxy(2,5);
	   play(show_3+15,7);
	   delay(500);
	   clear();
	   gotoxy(1,0);
	   play(show_8,15);
	   goto loop;
	  }
	  if(sum_1==0) 
	  {
	   
	   clear();
	   gotoxy(1,0);
	   play(show_6,15);
	   do
	   {
	   key();
	   }
	   while(ki!=13);
	   loop1:clear();
	   gotoxy(1,0);
	   play(show_7,13);
	   gotoxy(2,0);
	   play(show_7+13,15);
	   /****µÚÒ»´ÎÊäÃÜÂë***/
	   i=0;
	    do
	    {
		  flag=0;
          key();
		  if(flag==1&&ki<=9)
	      {
	       pswd[i]=ki;
		   i++;
		   clear();
		   gotoxy(1,0);
		   play(show_2,i);
		   }
	   	 }while(i<=7);
		 clear();
		 gotoxy(1,0);
	     play(show_8,15);
	   /***µÚ¶þ´ÎÊäÃÜÂë****/
		 i=0;
		 sum_1=0;
	    do
	    {
		  flag=0;
          key();
		  if(flag==1&&ki<=9)
	      {
	       pswd_1[i]=ki;
		   i++;
		   clear();
		   gotoxy(1,0);
		   play(show_2,i);
		   }
	   	 }
		 while(i<=7);
		 for(i=0;i<=7;i++)
		  {
		   sum_1=sum_1+ pswd_1[i]-pswd[i];
		   }
		 if(sum_1==0)
		   {
		    clear();
		   	gotoxy(1,2);
			play(show_9,12);
			gotoxy(2,2);
			play(show_9+13,11);
			for(i=0;i<=7;i++)
			{
			init_pswd[i]=pswd[1];
			 }
			while(1);
		   }
		 if(sum_1!=0)
		   {
		     clear();
		     goto loop1;
		   }
	  }	  
    } 
	   
	 
 }  
  
  
  

  • 更多单片机设计
  • https://gitee.com/lighter-z/graduation-design

全套资料免费下载:
关注v-x-公-众-号:【嵌入式基地
后-台-回-复:【毕业设计】 即可获资料
回复【编程】即可获取
包括有:C、C++、C#、JAVA、Python、JavaScript、PHP、数据库、微信小程序、人工智能、嵌入式、Linux、Unix、QT、物联网、算法导论、大数据等资料
在这里插入图片描述

  • 0
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

嵌入式基地

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值