I have code that uses a calculation using gyros in a forever loop. The purpose of the code is to turn a direction until goal is reached. But the code is just stuck in forever loop. I have played around calculations, did not help. How can I troubleshoot what is breaking in my forever loop? New to this programming. Thanks for any help
The pro forumers can’t help you with your code if they can’t see it. Copy and paste it here or take a screenshot of it so the can see where the bugs are.
forever loops last, as the name implies, forever. The program will stay in the loop until you tell it to leave with a break block, and right now you never tell it when to stop looping

To let your code leave the loop you need to either use a different type of loop which has an exit condition, like a while loop, or you need to run the break block when you want the loop to end.
the spinFor command will stop the motor when it’s completed its task. What you want to be doing is setting your velocity while you are moving your motor. What you’re actually doing is moving your motor for x degrees and then changing the velocity after it’s stopped. Also, why are you spinning your left motor for heading degrees? They’re two very different types of degrees and they probably should not be used together like that.
I had this issue a lot before too. I didn’t really end up solving it, unfortunately. What I will ask, though, is why you are using the momentum value? It honestly seems to me like you don’t need to use it and it will just complicate your code further.
I do know that what is happening is that your while loop’s parameters are being constantly engaged - I believe most likely to do with your inertial’s heading values.


