Shop OBEX P1 Docs P2 Docs Learn Events
Help! with compass — Parallax Forums

Help! with compass

NissaNissa Posts: 2
edited 2005-03-29 18:35 in Learn with BlocklyProp
hello, i have recently been working on creating a program that will start in one spot and use the compass to roam and avoid objects until it ends up back in the begining location. I wrote the code and thought it was ok but when i try and run it the bot doesn't do anything and i can't seem to see the problem.

Comments

  • edited 2005-03-29 18:23
    For starters, your newHeading and heading variables both intitialize to zeros, so the code ends right off the bat.

    Consider writing the program in smaller chunks.· For example, start with a program that displays the direction in the Debug Terminal.· When you know that works, comment out the debug code and then modifiy the program so that the Boe-Bot goes forward when it detects that it's pointing north.· Keep building it in small increments, and save under new file names frequently so that you can backtrack to older revisions.

    ·
  • NissaNissa Posts: 2
    edited 2005-03-29 18:30
    Thanks Andy!

    i'll try that and see how it turns out...tongue.gif
  • edited 2005-03-29 18:35
    Good luck.

    You can cause your current heading to be different from the old heading before the DO UNTIL...LOOP by adding a SERIN command to get an initial heading value before the DO...LOOP starts. You may also need to set oldHeading to a value if you expect the SERIN command to load a zero into the heading variable.
Sign In or Register to comment.