Boe Bot QTI
Canadianregional
Posts: 1
Hello all,
I am very new to this program and I have been trying to create a code to make my boe bot move through a maze using code i found online with my own changes. It hasent worked out so well... I am having trouble finding information about IF THEN routines in combo with CASE. If anyone can shed some light on this it would be greatly appreciated.
CODE:
' {$STAMP BS2}
' {$PBASIC 2.5}
i VAR BYTE
start:
qtis VAR NIB
OUTB = %11111
GOSUB Check_Qtis
SELECT qtis
CASE %00100
PULSOUT 13, 800
PULSOUT 12, 700
CASE %01000
PULSOUT 13, 800
PULSOUT 12, 725
CASE %00010
PULSOUT 13, 775
PULSOUT 12, 650
CASE %10000
PULSOUT 13, 775
PULSOUT 12, 735
CASE %00001
PULSOUT 13, 765
PULSOUT 12, 650
CASE %00000
DO
PULSOUT 13, 700
PULSOUT 12, 700
PAUSE 20
IF CASE %10000 OR CASE %11000 THEN EXIT
LOOP
CASE %11100
GOSUB leftTurn
CASE %00111
GOSUB rightTurn
CASE %11111
GOSUB inch
CASE %11111
END
ELSE
GOSUB leftTurn
ENDIF
ELSE
PULSOUT 13, 765
PULSOUT 12, 725
ENDIF
PAUSE 20
GOTO start
leftTurn:
GOSUB inch
DO
PULSOUT 13, 725
PULSOUT 12, 700
PAUSE 20
IF CASE %10000 OR CASE %11000 THEN EXIT
LOOP
RETURN
rightTurn:
GOSUB inch
DO
PULSOUT 13, 775
PULSOUT 12, 800
PAUSE 20
IF CASE %00001 OR CASE %00011 THEN EXIT
LOOP
RETURN
inch:
FOR i = 1 TO 5
PULSOUT 13, 800
PULSOUT 12, 700
PAUSE 20
NEXT
RETURN
left90:
FOR i = 1 TO 15
PULSOUT 13, 700
PULSOUT 12, 700
PAUSE 20
NEXT
RETURN
right90:
FOR i = 1 TO 15
PULSOUT 13, 800
PULSOUT 12, 800
PAUSE 20
NEXT
Also I have a question about the i variable and how it works? Like I said im pretty new to this.
Cheers
I am very new to this program and I have been trying to create a code to make my boe bot move through a maze using code i found online with my own changes. It hasent worked out so well... I am having trouble finding information about IF THEN routines in combo with CASE. If anyone can shed some light on this it would be greatly appreciated.
CODE:
' {$STAMP BS2}
' {$PBASIC 2.5}
i VAR BYTE
start:
qtis VAR NIB
OUTB = %11111
GOSUB Check_Qtis
SELECT qtis
CASE %00100
PULSOUT 13, 800
PULSOUT 12, 700
CASE %01000
PULSOUT 13, 800
PULSOUT 12, 725
CASE %00010
PULSOUT 13, 775
PULSOUT 12, 650
CASE %10000
PULSOUT 13, 775
PULSOUT 12, 735
CASE %00001
PULSOUT 13, 765
PULSOUT 12, 650
CASE %00000
DO
PULSOUT 13, 700
PULSOUT 12, 700
PAUSE 20
IF CASE %10000 OR CASE %11000 THEN EXIT
LOOP
CASE %11100
GOSUB leftTurn
CASE %00111
GOSUB rightTurn
CASE %11111
GOSUB inch
CASE %11111
END
ELSE
GOSUB leftTurn
ENDIF
ELSE
PULSOUT 13, 765
PULSOUT 12, 725
ENDIF
PAUSE 20
GOTO start
leftTurn:
GOSUB inch
DO
PULSOUT 13, 725
PULSOUT 12, 700
PAUSE 20
IF CASE %10000 OR CASE %11000 THEN EXIT
LOOP
RETURN
rightTurn:
GOSUB inch
DO
PULSOUT 13, 775
PULSOUT 12, 800
PAUSE 20
IF CASE %00001 OR CASE %00011 THEN EXIT
LOOP
RETURN
inch:
FOR i = 1 TO 5
PULSOUT 13, 800
PULSOUT 12, 700
PAUSE 20
NEXT
RETURN
left90:
FOR i = 1 TO 15
PULSOUT 13, 700
PULSOUT 12, 700
PAUSE 20
NEXT
RETURN
right90:
FOR i = 1 TO 15
PULSOUT 13, 800
PULSOUT 12, 800
PAUSE 20
NEXT
Also I have a question about the i variable and how it works? Like I said im pretty new to this.
Cheers
Comments
Dave