Find My Error Please
marcboebot
Posts: 5
For school, I am programming a boebot to go through a maze and up a ramp autonomously. I am using an accelerometer sensor to help my boebot go up the ramp. I need my boebot to stop when it gets to the top of the ramp. Right now, I have it programmed so that if y > 2500, gosub foward, and if y < 2500 stop. But I need to add this programming to the programming of the infrared sensors I am using. I don't want the boebot to stop moving until after it goes up the ramp, but with the programming I have right now, it won't begin moving unless it starts at a tilt. Is there a way to use an If Then command so I can say if y > 2500 and then y < 2500 then stop? Or is there another way to program it to only stop once its reached the top of the ramp?
Comments
Then once you test for a level condition and the Flag Bit has been asserted the inference would be that it's level again (at the top of the ramp).
if y < 2500 OR stopMoving = 1 then stop
the OR means it wuld stop as soon as one of the conditions are fulfilled.
stopMoving is a variable that keeps track of the state of the program. 0 is the initial state. 1 should be the state that y has decreased. The 3rd state is when y has decreased then increased which is caught by the IF statement. Your program doesn't have to remember the state because it stops at that point. Where do you set stopMoving to 1?