Single chip electronic password lock subroutine

Publisher:TP9111Latest update time:2015-06-24 Source: 51hei Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Simulation file and complete source code download address: http://www.51hei.com/bbs/dpj-22586-1.html
Thesis download address: http://www.51hei.com/f/Electronic password lock thesis final draft.docx
Below is the mima.c subroutine:

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

/*Compare password function , return 1 if the password is correct, return 0 if it is incorrect*/

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;
}

/*Select the password input or password change function, the password input returns A, the password change returns B*/

unsigned char step_choose(void)//Select to input password or modify password processing function
{
 uchar key;
 key = 0xff;
 write_com(0x06);//Address pointer plus 1 after writing a character 
    write_com(0x01);//Display clear, data pointer clear
 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;
}
/*Password input function, returns 1 if the password is correct, returns 0 if the password is wrong*/

bit  input_mima(uchar * mima)//Password input function
{
 unsigned char count,key;
 lcd_pos(1,0);
 for(count = 0; count < 7; count++)
 {
  delay_ms(100);
  if(count < 6)
  {
   do{key = keyscan();}//Scan keyboard
   while(key == 0xff);
   if((key != backspace) && (key != A) && (key != enter))//Neither backspace nor confirm key
   {
    write_data('*');//It is a numeric key display*
    mima[count] = key;
   // continue;
   }
   if(key == backspace)//It is a backspace key
   {
    if(count > 0)
    {
        lcd_pos(1,--count);//Move the cursor forward one
     positionwrite_data(' ');//Clear one
     positionmima[count] = ' ';//Write emptylcd_pos
     (1,count);
     count--;//The password counter decreases by one, because it will be +1 after the loop, so we need to add 1 here
    }
   }
   if(key == enter)//Password input is not completed and error message is returned
   {
    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)//The number of digits in the password is correct
   {
    return(1);//Return 1 correct signal
   }
  }
 }
 
}

Reference address:Single chip electronic password lock subroutine

Previous article:Single chip electronic password lock program (2)
Next article:Design of ultrasonic voice ranging cane based on single chip microcomputer

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号