3922 views|0 replies

1379

Posts

0

Resources
The OP
 

Experiment 2. Flowing lights [Copy link]

In the previous experiment, we made a light flash off, on, off, on. Then, if we turn on the second light instead of the first light after the first light goes out, and then turn on the third light after the second light goes out, and so on, wouldn't it become a running light? Let's take a look at how this running light is made.

Our "Programming Experiment Integrated Board" has been connected to 8 LEDs, so you can do this experiment without any modification. The wiring diagram is the same as the previous experiment, so refer to the picture of the previous experiment.

The procedures and meanings of the running lights are as follows:

star : ;Program starts
clr p1.0 ;clear p1.0, make it = 0, LED1 lights up
acall delay ;call delay subroutine
setb p1.0 ;set p1.0 high, make it = 1, LED1 turns off
clr p1.1 ;light up LED2
acall delay
setb p1.1 ;turn off LED2
clr p1.2 ;light up LED3
acall delay
setb p1.2 ;turn off LED3
clr p1.3 ;light up LED4
acall delay
setb p1.3 ;turn off LED4
clr p1.4 ;light up LED5
acall delay
setb p1.4 ;turn off LED5
clr p1.5 ;light up LED6
acall delay
setb p1.5 ;turn off LED6
clr p1.6 ;light up LED7
acall delay
setb p1.6 ;turn off LED7
clr p1.7 ;light up LED8
acall delay
setb p1.7 ;Turn off LED8
ljmp star ;Return to the beginning of the loop
delay : ;Delay subroutine
mov r1,#50
del0:
mov r2,#100
del1:
mov r3,#100
djnz r3,$
djnz r2,del1
djnz r1,del0
ret ;Delay subroutine ends, return to the next sentence of the call
end

Please save the above program as Test.asm, compile it, and burn it into stc89c51, then you can see the "flow"!

This post is from MCU
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

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