Shop OBEX P1 Docs P2 Docs Learn Events
PBasic question — Parallax Forums

PBasic question

AngDeaverAngDeaver Posts: 4
edited 2013-09-06 15:59 in Learn with BlocklyProp
I am trying to see if I can create a PBasic program on my own, to ensure that I am understanding the different concepts. To challenge me, even more, my husband has given me a list of maneuvers to try and make my Boe-Bot do.

The one I am currently stuck on is - he wants it to perform a figure 8, but if something touches it's whiskers for it to pause until it is no longer being touched and then continue on it's previous course. For the life of me I can't figure out how to make it continue from where it left off.

I was thinking I might be able to next an if...then...else statement, by having it track how far it was in the count (instead of how many times the whiskers were touched back and forth to initiate the U-turn). However, I am wondering if I bit off more than I can chew.

Is there a "continue" code out there somewhere?

Thanks in advance,
Ang

Comments

  • Hal AlbachHal Albach Posts: 747
    edited 2013-09-06 15:46
    I gather that the whiskers are not touching a wall or other household object that isn't going to move but more likely your husband nudging the whiskers while the BOE-Bot is performing its action. Make the whisker routine a sub-routine that is called by the program when a whisker event occurs. A Do..While loop can be used to wait until the whisker event is removed at which point a RETURN command will let the program continue until another whisker event takes place. (the Do..While is only available under PBasic 2.5). This suggestion is really only for someone actively nudging the whisker. Per your program requirements if the whisker touches a wall, it will not move away from the wall.
  • AngDeaverAngDeaver Posts: 4
    edited 2013-09-06 15:54
    That is exactly what I was after. Thank you. I think he does just want to nudge it and get in it's way, he's that kind of guy. :lol:
    I will try to write it up tonight.
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-09-06 15:59
    I don't program in PBasic much myself but I wanted to ask if you've gotten the robot to perform a figure 8? If not, I'd wait to add the other details until after you've got at least the figure 8 figured out (no, I didn't mean to do that).

    Once your robot is traveling in a figure 8, I hope you post a video to the figure 8 thread.

    In post #35 of my cheap bot thread, I give some pointers about programming a robot to drive in a figure 8. The code posted is for the Propeller but the principles are the same about using a "turn" value to adjust the speed of the servos.
Sign In or Register to comment.