Simple code not working

idk why this simple code isnt working. help pls

If what you want is “drive forward 200mm, then turn right 270 degrees”, you can do that with just two blocks:

1 Like

The issue is that the heading is probably never going to hit 270 flat. It only updates heading after a certain amount of time, and it’s likely to overshoot. Simple fix would be to change heading = 270 to heading > 270.

1 Like

same outcome 20chars

because of motor drift, it will go between 268 and 272. and i want it to be exact

If statements usually check the moment that the code reaches that point. Once it starts turning right, it will check if the heading = 270. Since it isn’t at that very moment, it moves on to the next line of code. You can use a wait until or a while depending on what you are trying to accomplish. Try that and see if it works out.


If you want to write code to turn the robot more precisely than the built-in “turn for” block, it will need to be more complicated than your current code. This video is a good place to start:

1 Like