Use this matrix keyboard as microcontroller input, plug it into P1.0~P1.6 of P1 port.
I want to ask, when:
When key 1 is pressed, P0.0 of P0 port outputs high level;
Press the 2 key and P0.1 outputs high level;
…
Just go up to the 8 key.
There is also a requirement that when a key is pressed, the delay is 5 seconds and other keys are locked, and then the program returns to the starting point after 5 seconds.
;=====================================================
; As follows:
ORG 0000H
START:
MOV P0, #255
MOV P1, #255
CLR P1.0
NOP
JNB P1.4, K1
JNB P1.5, K2
JNB P1.6, K3
MOV P1, #255
CLR P1.1
NOP
JNB P1.4, K4
JNB P1.5, K5
JNB P1.6, K6
MOV P1, #255
CLR P1.2
NOP
JNB P1.4, K7
JNB P1.5, K8
; JNB P1.6, K9
SJMP START
K1: CLR P0.0
SJMP DELAY
K2: CLR P0.1
SJMP DELAY
K3: CLR P0.2
SJMP DELAY
K4: CLR P0.3
SJMP DELAY
K5: CLR P0.4
SJMP DELAY
K6: CLR P0.5
SJMP DELAY
K7: CLR P0.6
SJMP DELAY
K8: CLR P0.7
DELAY:
MOV R5, #10
DJNZ R7, $
DJNZ R6, $ - 2
DJNZ R5, $ - 4
LJMP START
END
If you need to control the output of high level by key, change all CLR in the above program to SETB.
Then: MOV P0, #255
Change to: MOV P0, #0
Previous article:51 MCU interrupt architecture_interrupt response process
Next article:Discussion on Controlling AD9854 with 16-bit Single Chip Microcomputer
- Popular Resources
- Popular amplifiers
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
- Ranking of installed capacity of smart driving suppliers from January to September 2024: Rise of independent manufacturers and strong growth of LiDAR market
- Industry first! Xiaopeng announces P7 car chip crowdfunding is completed: upgraded to Snapdragon 8295, fluency doubled
- P22-009_Butterfly E3106 Cord Board Solution
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- 【ESP32-C3-DevKitM-1】ESP32-C3 connects to MQTT server
- MATLAB APP Designer serial port debugging tool writing
- [Zero-knowledge ESP8266 tutorial] Quick start 1-Let your development board say hello to the world
- EEWORLD University Hall----Engineering is smarter, industrial design is more powerful: TI robot system
- Analysis of the Principle of Power Switching Circuit
- Do you know? Use GPIO to simulate I2C communication on C2000
- Questions about UCOS II migration [Newbie help]
- New Technology for Air Quality Monitors and Smoke Detectors
- How to reduce 60V to 42V using LM34927
- Detailed explanation of STM32 minimum system circuit