Robots follow instructions by running a program, which is a list of steps written by a human. In block coding, each colorful block stands for a command, a question, or a repeated action. A robot reads these blocks in order, usually from top to bottom, and turns them into movement, sounds, lights, or decisions.
This matters because clear instructions help robots do useful jobs safely and correctly.
Understanding How Robots Follow Instructions
Inside a robot, a small computer called a controller turns program steps into electrical signals. Those signals reach motors, lights, speakers, or other output parts. A motor does not understand a word such as forward.
The controller must set its direction, power level, and running time. This is why a movement instruction can produce different results on different surfaces.
A robot may travel less far on carpet than on a smooth floor because its wheels slip or the battery is low. Good programs allow for these real physical limits.
A condition is a decision point. The robot checks whether a statement is true at that exact moment, then follows the matching path. This makes timing important.
If a robot checks for an obstacle only once before it starts moving, a person or object could enter its path later. A safer design checks repeatedly while the robot moves. Conditions can be combined to handle more than one situation.
For example, a robot can slow down when an object is nearby, stop when it is very close, and continue when the path becomes clear. The order of these checks matters because one rule may take priority over another.
Loops save space in a program, but they can cause trouble when their ending rule is unclear. A repeat loop runs a known number of times. A loop that continues until something happens depends on sensor readings.
If the sensor never detects the expected event, the robot may keep moving forever or remain stuck. Programmers often include a limit, such as stopping after a certain time or distance, as a backup.
This is common in real machines. A warehouse robot may try to find a line on the floor, but it should stop and signal for help if the line cannot be found.
Sensors do not give perfect information. A distance sensor may be affected by a soft curtain, a shiny surface, or a slanted wall. A light sensor changes when room lighting changes.
A touch sensor can miss a very gentle bump. Before using sensor values, students often need to test them in the actual environment. This is called calibration.
They can record what the sensor reads in bright and dim places, then choose a sensible boundary for a decision. When a robot behaves strangely, check one part at a time.
Test the sensor reading, test the motor action, then test the condition or loop. This method makes debugging less confusing and helps students find the exact instruction that needs changing.
Key Facts
- A program is a set of instructions that tells a robot what to do.
- Sequence means instructions run in order, usually from top to bottom.
- Command example: drive forward 20 cm tells the robot both the action and the distance.
- Condition example: if sensor sees wall, then stop makes the robot choose an action based on information.
- Loop example: repeat 4 times can help a robot make a square by repeating forward and turn commands.
- Sensor input is data from the robot's surroundings, such as light level, distance, touch, or sound.
Vocabulary
- Program
- A program is a set of instructions that a robot follows to complete a task.
- Command
- A command is a single instruction that tells a robot to do something specific.
- Sensor
- A sensor is a device that helps a robot detect information from its surroundings.
- Condition
- A condition is a rule that makes a robot do one action if something is true and another action if it is not.
- Loop
- A loop is a part of a program that repeats the same instructions a set number of times or until a condition is met.
Common Mistakes to Avoid
- Putting blocks in the wrong order: robots follow the sequence exactly, so a turn before a forward command can send the robot in the wrong direction.
- Forgetting to include a stop command: a robot may keep moving if the program never tells it when to stop or what condition should stop it.
- Using a loop without checking what is inside it: every block inside the loop repeats, so one extra turn or drive command can change the whole path.
- Ignoring sensor values: sensors give numbers or true-false information, so the program must use the correct threshold or condition to respond correctly.
Practice Questions
- 1 A robot has this program: repeat 4 times: drive forward 30 cm, turn right 90 degrees. What shape does it trace, and what total distance does it drive?
- 2 A robot moves forward at 10 cm per second. A command says drive forward for 6 seconds, then stop. How far does the robot travel?
- 3 A robot has a light sensor rule: if the light reading is less than 40, turn on headlights; otherwise keep headlights off. Explain what the robot should do in a dark room and why.