Hi,
I have build a small 'robot', based on two motors and a L293 Motor IC and two bumper switches at the front, left and right.
It's a really simple program.
When starting it will go forward until one bumper PIN get's down.
Then it should go backward for 2 seconds, make a little turn and go forward again.
This works for a couple of seconds. After that it seems that the 2000 delay is only a 2 delay.
I see that the motor stops, but it goes immediatly forward again.
Any ideas what happens here?
I use a 14M2 for this.
I have build a small 'robot', based on two motors and a L293 Motor IC and two bumper switches at the front, left and right.
It's a really simple program.
When starting it will go forward until one bumper PIN get's down.
Then it should go backward for 2 seconds, make a little turn and go forward again.
This works for a couple of seconds. After that it seems that the 2000 delay is only a 2 delay.
I see that the motor stops, but it goes immediatly forward again.
Any ideas what happens here?
I use a 14M2 for this.
Code:
main:
pullup on
pwmout pwmdiv64, B.2, 124, 0
pwmout pwmdiv64, B.4, 124, 0
pwmout pwmdiv64, C.0, 124, 0
pwmout pwmdiv64, C.2, 124, 0
gosub vor
do
if pinB.1 = 0 then
gosub rueck
gosub drehL
gosub vor
endif
if pinB.3 = 0 then
gosub rueck
gosub drehR
gosub vor
endif
loop
vor:
pwmout pwmdiv64, B.2, 124, 0
pwmout pwmdiv64, C.0, 124, 0
pwmout pwmdiv64, B.4, 124, 249
pwmout pwmdiv64, C.2, 124, 249
return
rueck:
pwmout pwmdiv64, C.2, 124, 0
pwmout pwmdiv64, B.4, 124, 0
pwmout pwmdiv64, B.2, 124, 249
pwmout pwmdiv64, C.0, 124, 249
pause 2000
return
drehL:
pwmout pwmdiv64, B.2, 124, 0
pwmout pwmdiv64, B.4, 124, 0
pwmout pwmdiv64, C.0, 124, 0
pwmout pwmdiv64, C.2, 124, 249
pause 500
return
drehR:
pwmout pwmdiv64, B.2, 124, 0
pwmout pwmdiv64, C.0, 124, 0
pwmout pwmdiv64, C.2, 124, 0
pwmout pwmdiv64, B.4, 124, 249
pause 500
return