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

looping question

ArchiverArchiver Posts: 46,084
edited 2000-10-19 19:44 in General Discussion
Here is my problem. I have an IR sensor that when triggered is
supposed to enter a loop. No the problem I am having is the loop
never executes. If I take out the pulsout commands, the loop runs
and x is incremented. When i put back in the pulsout commands, the
loop never loops, and the debug screen never displays the value for
x. Can somone please help me figure out what is goin on? Here is
the problematic code:

main:
freqout 1, 1, 38000
rightIRdet = in0
debug home, ? rightIRdet
if rightIRdet=0 then test
goto main

test:
for x=1 to 10
pulsout left_servo,850
pulsout right_servo,650
pause 20
debug ? x
next
goto main

Thanks
Ben

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2000-10-19 19:44
    Your stamp is probably being reset when you try to drive the servos. One
    way to prove this is place a debug statement before the "main" label. If
    the stamp is reseting, the debug statement will be executed every time you
    try the move the servo.

    At 02:10 PM 10/19/00 -0400, you wrote:
    >Here is my problem. I have an IR sensor that when triggered is
    >supposed to enter a loop. No the problem I am having is the loop
    >never executes. If I take out the pulsout commands, the loop runs
    >and x is incremented. When i put back in the pulsout commands, the
    >loop never loops, and the debug screen never displays the value for
    >x. Can somone please help me figure out what is goin on? Here is
    >the problematic code:
    >
    >main:
    >freqout 1, 1, 38000
    >rightIRdet = in0
    >debug home, ? rightIRdet
    >if rightIRdet=0 then test
    >goto main
    >
    >test:
    >for x=1 to 10
    >pulsout left_servo,850
    >pulsout right_servo,650
    >pause 20
    >debug ? x
    >next
    >goto main
    >
    >Thanks
    >Ben
    >
    >
    >
    >
    >
Sign In or Register to comment.