Shop OBEX P1 Docs P2 Docs Learn Events
i am having trouble getting a loop until to stop — Parallax Forums

i am having trouble getting a loop until to stop

sharon anthonysharon anthony Posts: 17
edited 2009-09-20 04:15 in BASIC Stamp
i have to make robot go 4 feet make right 90 degreee turn 7 times i used a counter vairable and a rep variable at the end but when i designate reps= reps + 1
the loop until (reps >=7) keeps saying i need a "TO" after the reps + 1. can you use the for next loop and at end just a do loop with the loop until?

sharon

Comments

  • FranklinFranklin Posts: 4,747
    edited 2009-09-20 02:44
    Attach your code to your next message.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • sharon anthonysharon anthony Posts: 17
    edited 2009-09-20 03:34
    not sure i know what that means.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-20 03:41
    If you use the Post Reply button, you'll see a button that allows you to upload a file as an attachment to your next message. Please use that to attach your source program to your message so we can see what you're trying to do. If you just cut and paste your code, you'll lose most of your code formatting because of how the forum software works.
  • sharon anthonysharon anthony Posts: 17
    edited 2009-09-20 03:52
    Thanks Mike i have the 90 degree turns working but it is drifting to the right so i lowered to 840 but havent tested it yet. biggest problem it wont stop after 7 sequences.

    thank u so much

    sharon
  • sharon anthonysharon anthony Posts: 17
    edited 2009-09-20 04:01
    hey mike sorry i forgot to hit that notify button i think i am also having trouble getting the darn thing to keep going straight
  • Mike GreenMike Green Posts: 23,101
    edited 2009-09-20 04:15
    1) Consider "reps" as uninitialized. Normally the Stamp clears all the variables to zero when it comes out of reset after a download. It's bad practice to assume that.

    2) Why not use a FOR loop like "FOR reps = 1 to 10" instead of the outer DO loop with "NEXT" instead of the "LOOP UNTIL"? It's much clearer.

    3) Your "reps = reps + 1" is outside of the DO / LOOP so "reps" never gets incremented beyond 1.

    4) Servos are not exact things so 750 (1500us) is not always the stop point for a continuous motion servo and 850 (1700us) and 650 (1300us) are not always symmetric speeds around the stop point. It helps if you calibrate the servo (as described in the "Robotics with the BoeBot" manual).
Sign In or Register to comment.