Chapter 2

Programming a Robotic System

Discover how a robotic system uses sensors, a controller and motors, guided by simple code you write.

Parts of a robotic system

A robotic system is a machine that can sense, decide and act on its own. It has three main jobs, which we call input, process and output.

  • Input: a sensor collects information, such as light, sound, touch or distance.
  • Process: the controller (a small computer) reads the input and follows the program.
  • Output: a motor, light or buzzer does the action.

Key idea

A robotic system follows the flow: input (sensor) → process (controller) → output (motor).

Writing simple code

A program is a list of clear steps the controller follows in order. We often use an if rule: if a condition is true, then do an action.

Example

If the distance sensor sees a wall, then stop the motor and turn. This stops a robot car from crashing.

Testing and fixing

After you run the code, you watch what the robot does. If it does the wrong thing, you find the mistake, called a bug, and change the code. Testing and fixing the code again and again makes the robot work well.

Stuck on this topic? A verified JomKelas tutor can walk you through it.

Find a verified tutor