3434 views|0 replies

1379

Posts

0

Resources
The OP
 

Presettable reversible 4-digit counter [Copy link]

1. Experimental tasks

Use P1.0-P1.3 of the microcontroller to connect four light-emitting diodes L1-L4 to indicate the current count data; use P1.4-P1.7 as the input end of the preset data, connect four toggle switches K1-K4, and use P3.6/WR and P3.7/RD ports to connect two touch switches to act as add-count and subtract-count switches. The specific circuit schematic is shown in the figure below.

2. Circuit diagram

3. Hardware connection on the system board

(1) Remove the short-circuit cap of P0.0-05 pin
. (2) Change the status of K1-K4 by connecting P0.0-P0.3 pins to the positive and negative poles.
(3) Connect the common line at the bottom of the button to the negative pole, and the buttons of P0.6 and P0.7 pins are effective.

4. Programming content
(1. Processing of two independent key recognitions;
(2. Problems with reading preset initial values
; (3. LED output indication

5. Flowchart

6. 汇编源程序
COUNT EQU 30H
ORG 00H
START: MOV A,P3
ANL A,#0FH
MOV COUNT,A
MOV P1,A
SK2: JB P3.6,SK1
LCALL DELY10MS
JB P3.6,SK1
INC COUNT
MOV A,COUNT
CJNE A,#16,NEXT
MOV A,P3
ANL A,#0FH
MOV COUNT,A
NEXT: MOV P1,A
WAIT: JNB P3.6,WAIT
LJMP SK2
SK1: JB P3.7,SK2
LCALL DELY10MS
JB P3.7,SK2
DEC COUNT
MOV A,COUNT
CJNE A,#0FFH,NEX
MOV A,P3
ANL A,#0FH
MOV COUNT,A
NEX: MOV P1,A
WAIT2: JNB P3.7,WAIT2
LJMP SK2
DELY10MS: MOV R6,#20
MOV R7,#248
D1: DJNZ R7,$
DJNZ R6,D1
RET
END

This post is from MCU
 

Guess Your Favourite
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list