给大家分享一个单片机做的LOVE彩灯。
单片机源程序:
- ORG 0000H
- LJMP START
- ORG 0030H
- ;初始化
- START: MOV DPTR,#TAB
- MOV R0,#00H;从00开始计数
- MAIN: MOV A,R0
- MOVC A,@A+DPTR
- MOV P0,A
- MOV P1,A
- LCALL DELAY
- LCALL DELAY
- INC R0
- CJNE R0,#46,MAIN
- MOV R0,#00H
- LJMP MAIN
- ;闪烁延时函数
- DELAY:MOV R5,#20
- D1:MOV R6,#20
- D2:MOV R7,#248
- DJNZ R7,$
- DJNZ R6,D2
- DJNZ R5,D1
- RET
- ;查表
- TAB: DB 0FEH,0FDH,0FBH,0F7H,0EFH,0DFH,0BFH
- DB 0FFH,00H,0FFH,00H,0FFH,00H,0FFH
- DB 0BFH,0DFH,0EFH,0F7H,0FBH,0FDH,0FEH
- DB 0FFH,00H,0FFH,00H,0FFH,00H,0FFH
- DB 0FCH,0F9H,0F3H,0E7H,0CFH,9FH
- DB 0FFH,00H,0FFH,00H,0FFH,00H,0FFH
- DB 9FH,0CFH,0E7H,0F3H,0F9H,0FCH
- END
复制代码
仿真工程文件及所有完整程序等资料下载地址:
http://www.51hei.com/bbs/dpj-56304-1.html
|