标题:
led灯以随机次数闪烁 单片机汇编语言程序
[打印本页]
作者:
illhurt
时间:
2019-7-27 09:20
标题:
led灯以随机次数闪烁 单片机汇编语言程序
8盏led灯以随机数点亮
单片机源程序如下:
;===============================================================================
; Key-LED
; AT89C2051,12Mhz,1 Key,1 LED
;===============================================================================
KeyPort Bit P3.0 ;0:Pressed
LEDPort EQU P1
;===============================================================================
;===============================================================================
;===============================================================================
Org 0000H
AJmp Main
;===============================================================================
Delay: Mov R6,#0
Delay1: Mov R7,#0
Djnz R7,$
Djnz R6,Delay1
Ret
;-------------------------------------------------------------------------------
FlashLED:
mov LedPort,B
;Clr LEDPort ;Light up
ACall Delay
Mov A,B
Cpl A
mov LedPort,A
;Setb LEDPort ;Dark
ACall Delay
Ret
;===============================================================================
Main: Mov Sp,#07H
Mov A,#1
; Mov LedPort,#00000001b
; Mov A,LedPort
;-------------------------------------------------------------------------------
MainLoop: Jb KeyPort,loop
Acall Delay
Inc A ;add the number of lighting
Acall Delay
;Acall Delay
;Acall Delay
CJNE A,#15,Mainloop
; Acall Delay
clr A
sjmp Mainloop
loop: ;Jb KeyPort,MainLoop ;No Key, Wait
Mov R5,A
Mov B,A
Mov A,LedPort
Clr A
L: ACall FlashLED
Djnz R5,L
Jb KeyPort,$
SJmp MainLoop
;===============================================================================
End
复制代码
所有资料51hei提供下载:
拓展.zip
(57.4 KB, 下载次数: 4)
2019-7-27 09:19 上传
点击文件名下载附件
下载积分: 黑币 -5
欢迎光临 (http://www.51hei.com/bbs/)
Powered by Discuz! X3.1