ZzzZzz
ZzzZzz

Reputation: 1

Sphero: Getting bolt to move based on distance programmed?

I am having trouble getting Bolt to stop moving after moving 5cm (It is not stopping). Can someone tell me what I'm doing wrong?

Blocks

Upvotes: -1

Views: 211

Answers (1)

Starship
Starship

Reputation: 715

Instead of using distance === dist, use distance >= dist and your problem should be fixed.

Your current code will only stop the bolt if it is at a distance of precisely 5. Unless you get extremely lucky, and the program happens to run through that part of the code at the point were the distance is exactly 5, it won't stop. By making stop if it greater than or equal to 5, the program will still stop it if you slightly overshoot 5.

Upvotes: 0

Related Questions