本人从初中就对电子,无线电产生了浓厚的兴趣,至今已有10年的时间了。我对模拟电子技术和数字电子技术还算比较熟悉吧,实践上也不算赖。但对单片机我才是刚刚学,是一个单片机初学者。对单片机还比较陌生。学了一段时间的单片机,给我的感觉就是它太强大了!太好玩了!太有意思了!它可以用最简单的硬件电路,依靠程序来实现复杂的控制。流水灯就是一个很好的例子。下面我就给大家介绍一下我做的具有30种花样的流水灯,和大家一起分享。
本花样流水灯,主要是由AT89S51单片机及8个不同颜 {MOD}的发光二极管组成。共有30种花样。运用“MOV A,#data,RL,RR,INC,DEC”指令编出各种花样的数据码,并将这些数据码送入端口(P0口)显示。广泛的应用于商场,饭店,超市,KTV,广场等地方。
注:晶振12MHZ,本程序已通过实践验证!!!
c8a08fb40310d5c730add168.jpg (616.86 KB, 下载次数: 0)
下载附件
30种花样流水灯
2012-4-1 20:49 上传
汇编源程序
30种花样流水灯.zip
(864 Bytes, 下载次数: 158)
2012-4-1 20:53 上传
点击文件名下载附件
- ORG 0000H
- MOV P0,#0FFH
- START:MOV R0,#8
- MOV A,#0FEH
- LOOP1:MOV P0,A
- ACALL DELAY
- RL A
- DJNZ R0,LOOP1
- MOV R1,#8
- MOV A,#7FH
- LOOP2:MOV P0,A
- ACALL DELAY
- RR A
- DJNZ R1,LOOP2
- MOV R2,#4
- LOOP3:MOV P0,#55H
- ACALL DELAY
- MOV P0,#0AAH
- ACALL DELAY
- DJNZ R2,LOOP3
- MOV R3,#3
- LOOP4:MOV P0,#7EH
- ACALL DELAY
- MOV P0,#0BDH
- ACALL DELAY
- MOV P0,#0DBH
- ACALL DELAY
- MOV P0,#0E7H
- ACALL DELAY
- MOV P0,#0DBH
- ACALL DELAY
- MOV P0,#0BDH
- ACALL DELAY
- MOV P0,#7EH
- DJNZ R3,LOOP4
- MOV R3,#3
- LOOP5:MOV P0,#0E7H
- ACALL DELAY
- MOV P0,#0DBH
- ACALL DELAY
- MOV P0,#0BDH
- ACALL DELAY
- MOV P0,#7EH
- ACALL DELAY
- MOV P0,#0BDH
- ACALL DELAY
- MOV P0,#0DBH
- ACALL DELAY
- MOV P0,#0E7H
- ACALL DELAY
- DJNZ R3,LOOP5
- MOV R4,#3
- LOOP6:MOV P0,#00H
- ACALL DELAY
- MOV P0,#18H
- ACALL DELAY
- MOV P0,#3CH
- ACALL DELAY
- MOV P0,#7EH
- ACALL DELAY
- MOV P0,#0FFH
- ACALL DELAY
- DJNZ R4,LOOP6
- MOV R4,#3
- LOOP7:MOV P0,#00H
- ACALL DELAY
- MOV P0,#81H
- ACALL DELAY
- MOV P0,#0C3H
- ACALL DELAY
- MOV P0,#0E7H
- ACALL DELAY
- MOV P0,#0FFH
- ACALL DELAY
- DJNZ R4,LOOP7
- MOV R4,#3
- LOOP8:MOV P0,#0EFH
- ACALL DELAY
- MOV P0,#0CFH
- ACALL DELAY
- MOV P0,#8FH
- ACALL DELAY
- MOV P0,#0FH
- ACALL DELAY
- MOV P0,#0F7H
- ACALL DELAY
- MOV P0,#0F3H
- ACALL DELAY
- MOV P0,#0F1H
- ACALL DELAY
- MOV P0,#0F0H
- ACALL DELAY
- DJNZ R4,LOOP8
- MOV R4,#4
- MOV A,#0EFH
- LOOP9:MOV P0,A
- ACALL DELAY
- RL A
- DJNZ R4,LOOP9
- MOV R4,#4
- MOV A,#0F7H
- LOOP10:MOV P0,A
- ACALL DELAY
- RR A
- DJNZ R4,LOOP10
- MOV R5,#9H
- MOV A,#00H
- MOV P0,A
- LOOP11:INC A
- MOV P0,A
- RL A
- ACALL DELAY
- DJNZ R5,LOOP11
- MOV R5,#9
- MOV A,#00H
- MOV P0,A
- LOOP12:INC A
- RR A
- MOV P0,A
- ACALL DELAY
- DJNZ R5,LOOP12
- MOV R5,#9
- MOV A,#00H
- MOV P0,A
- LOOP13:DEC A
- MOV P0,A
- RL A
- ACALL DELAY
- DJNZ R5,LOOP13
- MOV R5,#9
- MOV A,#00H
- MOV P0,A
- LOOP14:DEC A
- RR A
- MOV P0,A
- ACALL DELAY
- DJNZ R5,LOOP14
- MOV R5,#4
- MOV A,#00H
- LOOP15:MOV P0,A
- ACALL DELAY
- MOV P0,#0FFH
- ACALL DELAY
- DJNZ R5,LOOP15
- MOV P0,#00H
- MOV R0,#8
- MOV A,#01H
- LOOP16:MOV P0,A
- ACALL DELAY
- RL A
- DJNZ R0,LOOP16
- MOV R1,#8
- MOV A,#80H
- LOOP17:MOV P0,A
- ACALL DELAY
- RR A
- DJNZ R1,LOOP17
- MOV R2,#4
- LOOP18:MOV P0,#0AAH
- ACALL DELAY
- MOV P0,#55H
- ACALL DELAY
- DJNZ R2,LOOP18
- MOV R3,#3
- LOOP19:MOV P0,#81H
- ACALL DELAY
- MOV P0,#42H
- ACALL DELAY
- MOV P0,#24H
- ACALL DELAY
- MOV P0,#18H
- ACALL DELAY
- MOV P0,#24H
- ACALL DELAY
- MOV P0,#42H
- ACALL DELAY
- MOV P0,#81H
- DJNZ R3,LOOP19
- MOV R3,#3
- LOOP20:MOV P0,#18H
- ACALL DELAY
- MOV P0,#24H
- ACALL DELAY
- MOV P0,#42H
- ACALL DELAY
- MOV P0,#81H
- ACALL DELAY
- MOV P0,#42H
- ACALL DELAY
- MOV P0,#24H
- ACALL DELAY
- MOV P0,#18H
- ACALL DELAY
- DJNZ R3,LOOP20
- MOV R4,#3
- LOOP21:MOV P0,#0FFH
- ACALL DELAY
- MOV P0,#0E7H
- ACALL DELAY
- MOV P0,#0C3H
- ACALL DELAY
- MOV P0,#81H
- ACALL DELAY
- MOV P0,#00H
- ACALL DELAY
- DJNZ R4,LOOP21
- MOV R4,#3
- LOOP22:MOV P0,#0FFH
- ACALL DELAY
- MOV P0,#7EH
- ACALL DELAY
- MOV P0,#3CH
- ACALL DELAY
- MOV P0,#18H
- ACALL DELAY
- MOV P0,#00H
- ACALL DELAY
- DJNZ R4,LOOP22
- MOV R4,#3
- LOOP23:MOV P0,#10H
- ACALL DELAY
- MOV P0,#30H
- ACALL DELAY
- MOV P0,#70H
- ACALL DELAY
- MOV P0,#0F0H
- ACALL DELAY
- MOV P0,#08H
- ACALL DELAY
- MOV P0,#0CH
- ACALL DELAY
- MOV P0,#0EH
- ACALL DELAY
- MOV P0,#0FH
- ACALL DELAY
- DJNZ R4,LOOP23
- MOV R4,#4
- MOV A,#10H
- LOOP24:MOV P0,A
- ACALL DELAY
- RL A
- DJNZ R4,LOOP24
- MOV R4,#4
- MOV A,#08H
- LOOP25:MOV P0,A
- ACALL DELAY
- RR A
- DJNZ R4,LOOP25
- MOV R5,#9H
- MOV A,#00H
- MOV P0,A
- LOOP26:INC A
- MOV P0,A
- RL A
- ACALL DELAY
- DJNZ R5,LOOP26
- MOV R5,#9
- MOV A,#0FFH
- MOV P0,A
- LOOP27:INC A
- RR A
- MOV P0,A
- ACALL DELAY
- DJNZ R5,LOOP27
- MOV R5,#9
- MOV A,#0FFH
- MOV P0,A
- LOOP28:DEC A
- MOV P0,A
- RL A
- ACALL DELAY
- DJNZ R5,LOOP28
- MOV R5,#9
- MOV A,#0FFH
- MOV P0,A
- LOOP29:DEC A
- RR A
- MOV P0,A
- ACALL DELAY
- DJNZ R5,LOOP29
- MOV R5,#4
- MOV A,#0FFH
- LOOP30:MOV P0,A
- ACALL DELAY
- MOV P0,#00H
- ACALL DELAY
- DJNZ R5,LOOP30
- LJMP START
- DELAY:MOV R7,#00H
- L1:MOV R6,#00H
- L2:DJNZ R6,L2
- DJNZ R7,L1
- RET
- END
-
复制代码有电路图更好
我更感兴趣的不是代码,而是功能,到底这30种花样是啥花样
一周热门 更多>