;On some touch-screen phones, there is a slide-to-unlock operation.
;On laptops, passwords are usually entered using the keyboard.
;Some people set the password to: ASDFGHJKL;'Enter. When turning on the computer, just swipe your finger on the keyboard.
; For single-chip microcomputers, you can also set passwords in this form. By pressing certain keys in sequence, you can successfully enter the next step.
;The circuit in the figure below is to press the keys in sequence to enter the power-on password:
;P1.0 to P1.5 are password keys, P1.7 is the confirmation key,
; P2.1 to P2.6 correspond to 5 password keys, normally lit, --- the original text says so, should be 6
;After pressing the corresponding password, the corresponding LED goes out, and lights up again when you release it.
;The blue LED on P2.7 corresponds to the confirmation key.
; The password sequence is P1.0 to P1.5,
;The LED on P1.6 will light up only if the password value and sequence are correct, otherwise the red LED on P2.0 will light up.
;The original program in the title is not available.
; Following the idea of the original program, the program written by Erlundao is as follows:
;-----------------------------------------
ORG 0000H
JMP START
START:
MOV R0, #7; Use R0 as a counter to check the password sequence
CLR P1.6 ; Turn off the correct indicator light
MOV P2, #01111110B; P2.1 to P2.6 correspond to 6 password keys, which are normally lit.
LOOP:
MOV A, P1 ; read
MOV B, A ;temporary storage
ORL A, #01000000B ; Shield indicator light
CPL A
JZ LOOP; No key pressed, loop detection
CALL DL20MS ; Delay
MOV A, P1 ; read again
CJNE A, B, LOOP; debounce
;-----------------------------------------
; It has been confirmed that a key has been pressed:
MOV C, ACC.7 ;P1.7 key
CPL C
RL A
MOV ACC.7, C ; send to P2.7
CLR ACC.0 ; Turn off the error indicator
MOV P2, A; drives the indicator lights of each button
;-----------------------------------------
; Wait for release below
LOP2:
MOV A, P1 ; read
ORL A, #01000000B ; Shield indicator light
CPL A
JNZ LOP2 ; loop detection, waiting for release
;-----------------------------------------
;The key has been released,
MOV P2, #01111110B; P2.1 to P2.6 correspond to 6 password keys, which are normally lit.
;-----------------------------------------
; The following handles the key just pressed
JNB B.0, KEY0
JNB B.1, KEY1
JNB B.2, KEY2
JNB B.3, KEY3
JNB B.4, KEY4
JNB B.5, KEY5
JNB B.7, KEY7
JMP LOOP
;-----------------------------------------
KEY0:
CJNE R0, #7, LOOP
DEC R0
JMP LOOP
KEY1:
CJNE R0, #6, LOOP
DEC R0
JMP LOOP
KEY2:
CJNE R0, #5, LOOP
DEC R0
JMP LOOP
KEY3:
CJNE R0, #4, LOOP
DEC R0
JMP LOOP
KEY4:
CJNE R0, #3, LOOP
DEC R0
JMP LOOP
KEY5:
CJNE R0, #2, LOOP
DEC R0
JMP LOOP
KEY7:
CJNE R0, #1, ERROR
MOV P2, #0 ; Turn off the button indicator light
SETB P1.6 ; Correct indication
SJMP $ ; stop
ERROR:
MOV P2, #0 ; Turn off the button indicator light
SETB P2.0 ; Error indication
SJMP $ ; stop
;-----------------------------------------
DL20MS:
MOV R6, #40
DJNZ R7, $
DJNZ R6, $ - 2
RET
;-----------------------------------------
END
Previous article:51 MCU Assembly Programming: Recording Keystrokes
Next article:51 MCU Programming: Dual Counter
- Popular Resources
- Popular amplifiers
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- Mentor Usage Problems
- Ethernet Problems
- If you want to know whether the signal generated by the signal generator or function generator is ready or whether it is input according to the set value standard...
- MicroPython precompiled firmware for TB-01 (W600)
- Is it necessary to attend Altium's offline training?
- How to prevent audio equipment from aging and make the sound better
- Find TPS929120 library files
- [Atria Development Board AT32F421 Review] SPI Usage
- Discussion on BQ35100 Li-ion Battery Capacity Monitoring
- Evaluation: STM32F769I-DISCO connected to Gizwits Cloud to realize IoT development remote control and other functions