这个是用汇编语言编写的程序,没有C语言那么复杂,更好理解
单片机源程序如下:
- ORG 0080H
- MAIN:SETB P0.6
- SETB P0.7
- SETB P2.0
- MOV P1,#11111111B
- CLR P0.1
- SETB P0.0
- CLR P0.3
- SETB P0.2
- JNB P3.6,WW
- JB P3.5,QQ
- JB P3.7,QQ
- JB P0.5,LL
- JNB P3.4,TT
- MOV R0,#0
- LJMP MAIN
- WW:SETB P0.1
- SETB P0.3
- CLR P0.6
- MOV P1,#00000000B
- CLR P0.7
- CLR P2.0
- LCALL YANSHI1
- MOV P1,#11111111B
- SETB P0.7
- SETB P2.0
- LCALL YANSHI1
- INC R0
- MOV A,R0
- CJNE A,#5,WW
- SETB P0.6
- CLR P0.0
- SETB P0.1
- CLR P0.2
- SETB P0.3
- LCALL YANSHI2
- CLR P0.1
- SETB P0.0
- CLR P0.2
- SETB P0.3
- CLR P0.7
- LCALL YANSHI1
- LJMP MAIN
- QQ:SETB P0.1
- SETB P0.3
- LCALL YANSHI1
- CLR P0.0
- SETB P0.1
- CLR P0.2
- SETB P0.3
- LCALL YANSHI2
- CLR P0.1
- SETB P0.0
- CLR P0.2
- SETB P0.3
- CLR P2.0
- LCALL YANSHI1
- LJMP MAIN
- TT:SETB P0.1
- SETB P0.3
- CLR P0.6
- LCALL YANSHI3
- LJMP MAIN
- LL:CLR P0.1
- SETB P0.0
- CLR P0.3
- SETB P0.2
- CLR P0.7
- CLR P2.0
- MOV P1,#01111111B
- LCALL YANSHI
- MOV P1,#00111111B
- LCALL YANSHI
- MOV P1,#00011111B
- LCALL YANSHI
- MOV P1,#00001111B
- LCALL YANSHI
- MOV P1,#00000111B
- LCALL YANSHI
- MOV P1,#00000011B
- LCALL YANSHI
- MOV P1,#00000001B
- LCALL YANSHI
- MOV P1,#00000000B
- LCALL YANSHI
- JNB P0.5,PP
- LJMP LL
- PP:LJMP MAIN
- YANSHI1:
- MOV R6,#8
- LOOP6:MOV R5,#250
- LOOP5:MOV R4,#250
-
- LOOP4:DJNZ R4,LOOP4
- DJNZ R5,LOOP5
- DJNZ R6,LOOP6
- RET
- YANSHI2:
- MOV R3,#16
- LOOP3:MOV R2,#250
- LOOP2:MOV R1,#250
-
- LOOP1:DJNZ R1,LOOP1
- DJNZ R2,LOOP2
- DJNZ R3,LOOP3
- RET
- YANSHI:
- MOV 32H,#4
- LOOP9:MOV 31H,#250
- LOOP8:MOV 30H,#250
-
- ……………………
- …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码
所有资料51hei提供下载:
小车程序.rar
(527 Bytes, 下载次数: 9)
|