Making a Robot Think · Lesson 9 of 11
Loops and repetition
Doing it again and again
A robot does not decide once. It senses, decides, and acts over and over, many times a second. That repetition is a loop, and it is what makes a robot react in real time.
Python
Run it to watch the robot react as the obstacle gets closer. On a real robot this loop never ends; it keeps reading the live sensor and acting on the latest value.
Practice
In your own words, why must a robot loop instead of deciding just once? Give one example of what would go wrong if it checked its sensor only a single time.
You’re reading for free. Sign in to keep your progress and earn a certificate when you finish.Sign in to keep my progress →