Quote:
Originally posted by frumious
if counter++ > 500 then 'arbitrary time value
p1_x = 254
else
p1_x = 0
endif
|
Yeah, that will work as long as you ditch the ++ part. Doing a little C recently?
Anyway, dead-reckoning with the 2.5 syntax begs you to use the SELECT:
Code:
counter var word
counter=0
do
serin ....
IF auton_mode = 1 then
SELECT counter
CASE 0 to 100
PWM1=254
PWM2=254
counter=counter+1
CASE 101 to 200
PWM1=254
PWM2=0
counter=counter+1
CASE else
PWM1=127
PWM2=127
ENDSELECT
ELSE
'regular code goes here
ENDIF
serout...
LOOP
This code will go forward for approx. 2.6 seconds, then turn for another 2.6. To add new steps, just add another CASE. After it's done, it just stops and no longer incremements the counter. If you put the counter incrementer outside the SELECT, it will loop back to 0 after approx. 28 minutes. This may be OK, it may not.