📄 prog36.asm
字号:
; PROG36 - Getting 51 Bot's Wheels Turning
;
;
; This is the first program of the "51Bot" and Will be Used to Start
; turning the wheels. The Robot will go forward for 2 Seconds and then
; turn to the right for one second and then repeat the going forward for
; 2 seconds.
;
; Myke Predko
; 98.03.22
;
; Hardware Notes:
; AT89C2051 is used as the Microcontroller
; - Oscillator Speed is 20 MHz
; Wheel PWM Control is at P1.3
; Left Motor Control 1 is at P1.6
; Left Motor Control 2 is at P1.2
; Right Motor Control 1 is at P1.7
; Right Motor Control 2 is at P1.4
; LED Control is at P1.5
; Constant Declarations
; Variable Declarations
DlayVar EQU 030h ; Delay Subroutine Variables - 3 Bytes
; Macros
; Mainline
org 0 ; Execution Starts Here
Loop: ; Loop Around Here
acall Forward ; Go Forward for two Seconds
acall Dlay
acall Dlay
acall Right ; Turn Right for one Second
acall LED_ON
acall Dlay
acall LED_OFF ; Turn OFF the LED
ajmp Loop
Left: ; Turn Left
mov A,#%00100011 ; Clear the P1 Bits NOT Doing Motion
anl A,P1
orl A,#%11001000 ; Enable the Robot to Go Forwards
mov P1,A
ret
Right: ; Turn Right
mov A,#%00100011 ; Clear the P1 Bits NOT Doing Motion
anl A,P1
orl A,#%00011100 ; Enable the Robot to Go Forwards
mov P1,A
ret
Backward: ; Go Backwards
mov A,#%00100011 ; Clear the P1 Bits NOT Doing Motion
anl A,P1
orl A,#%01011000 ; Enable the Robot to Turn Right
mov P1,A
ret
Forward: ; Go Forward
mov A,#%00100011 ; Clear the P1 Bits NOT Doing Motion
anl A,P1
orl A,#%10001100 ; Enable the Robot to Turn Right
mov P1,A
ret
LED_ON: ; Turn On the LED
clr P1.5 ; Clear the LED Bit
ret
LED_OFF: ; Turn OFF the LED
setb P1.5
ret
Dlay: ; One Second Delay (1,666,666 Cycles)
mov DlayVar,#0 ; Set the 1 Second Delay Variables
mov DlayVar+1,#179
mov DlayVar+2,#13
DlayLoop: ; Delay Loop for 1 Second
djnz DlayVar,DlayLoop ; Loop for 1,666,666 Cycles
djnz DlayVar+1,DlayLoop
djnz DlayVar+2,DlayLoop
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -