VEX IQ Gyro Code Causing Robot To Spin Forever

We got this code from a Caution Tape video, and from what we see it is copied exactly. When we run the code, the robot will spin in one direction forever, and we can’t figure out why. We replaced the gyro and the wire to see if it was a faulty gyro and/or wire, but the issue still remained. If anyone knows what could be wrong, please help!

Oops, I forgot the video link so here it is How to program VEX IQ precise turns with gyro using VEXcode blocks - YouTube

I’m not sure 100% but I remember like a year ago I had the same problem and just removing the gyro and using the brain worked. But, if you really wanna use the gyro I’m not sure.

Do you have your motors reversed? According to your code, it should turn left (executing the first while loop), which should cause the gyro to increase its calculated rotational degrees and stop once it almost makes a full turn.

If your motors are reversed and the first while loop causes the robot to turn right instead of left you’ll go into an infinite spin since turning right will cause the gyro’s calculated rotational degrees to go in the negative direction and hence the first while loop condition will always be true and your code will never exit from the loop.

We reversed the motors and still have the same problem. Our suspicion is that the greater than and less than signs are somehow flipped wrong, so the gyro value never goes above the heading and it just spins forever. But, we tried a whole lot of different combinations and can’t get it to work.

Update: we got it to work. Turns out the problem was much simpler than expected: the number 8 port in which we had our gyro in turned out to be a faulty port. Thank you to @spaghetti_code and @superman34525 for helping

1 Like