Hardware or Code?

I am loading this code onto a boe bot, and it seems to take it, but when it pauses, instead of turning left or right, or going backwards, it just goes forward. Am I missing something with this code? I'm attempting to help a high school student with their homework, and I am at a loss.

' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
counter VAR Word
FREQOUT 4, 2000, 3000 ' Signal program start/reset.
FOR counter = 1 TO 64 ' Forward

PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20

NEXT

PAUSE 200

FOR counter = 1 TO 24 ' Rotate left - about 1/4 turn
PULSOUT 13, 650
PULSOUT 12, 650
PAUSE 20

NEXT

PAUSE 200

FOR counter = 1 TO 24 ' Rotate right - about 1/4 turn
PULSOUT 13, 850
PULSOUT 12, 850
PAUSE 20

NEXT

PAUSE 200

FOR counter = 1 TO 64 ' Backward
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20

NEXT

END

Comments

  • Bad batteries, causing it to reset itself and start all over again?
  • The code looks correct.

    As Banjo pointed out, batteries are usually the culprit when it does something it's not supposed to.

    Do you hear a beeping noise coming from the Piezo Speaker?
  • LegottoLegotto Posts: 2
    edited 2020-12-11 13:33
    No, no beeping, and we bought a new pack of batteries to test that theory out, and we have the same issue. I'm actually seriously wondering if it is just this one bot that is having an issue. The student I'm working with, she is 4 weeks of work ahead of the class, so none of the other students have even gotten to the point where she is at yet.

    The bot can do all of these commands independently, but when you combine them into one file, and load it onto the bot, it only goes forward.
  • When I get in situation like this, I put "flags" or short & simple print statements in the different code segments to let me know when or if I entered a function or not. That way you have a listing of everything the code is supposed to do.

    FOR counter = 1 TO 64 ' Backward
    PULSOUT 13, 650
    PULSOUT 12, 850
    PAUSE 20
    Print "Entered BACKWARD Cntr ="; counter
    NEXT
Sign In or Register to comment.