🚧 If… then…: sensors make decisions
Unit 2 · Loops & decisions · 9 min
An ultrasonic sensor measures distance. Program: if distance < 20 cm, stop and turn right; else keep going. Put that “if” inside a loop and the robot keeps avoiding obstacles on its own.
Words in this lesson
- if — if
- else — else
- distance — distance
Project: Draw a flowchart for your morning: “if it rains take an umbrella, else wear a cap”. Add two decisions of your own.