One-sentence summary
Coding is how we tell a system what to do using clear, ordered steps; robotics is how those instructions are carried out in the physical world through sensors, electronic parts and moving mechanisms.
What will you learn in this lesson?
By the time you finish this lesson, you should be able to:
- Explain how coding and robotics are connected,
- Recognise the basic parts of a robot,
- Tell the difference between a sensor, a control unit and an actuator,
- Understand that not every automatic machine is a robot,
- Set up the sense–decide–move loop of a simple robotic system.
Why does it matter?
When we look at a robot, the first thing we usually notice is that it moves. But movement is only the visible last step. A robot first gathers information from its surroundings, then weighs up that information, and only after that produces a response. Coding builds the decision logic; the electronic parts carry the information; and the mechanical system performs the movement.
Learning robotics and coding together teaches more than how to build a device. It also teaches you to describe a problem clearly, to break a solution into small pieces, to try things out, to measure, and to fix mistakes.
What is coding?
Coding is the work of telling a computer, phone, game character or control board which steps to follow, using a particular programming language.
Imagine we want a game character to move forward when the right arrow key is pressed. As people, saying "go right" might seem enough. A computer, though, needs clearer logic:
If the right arrow key is pressed
increase the character's x position by 10
This short example holds three important ideas:
- An event happens: the right arrow key is pressed.
- The system checks a condition.
- The character's position is changed.
Programming languages can look very different, but the core idea is the same: take an input, process it according to a rule, and produce an output.
What is robotics?
Robotics is the field concerned with building machines in which software, electronics and mechanical systems work together to sense their surroundings, make decisions and carry out a task.
A robotic system usually has these three stages:
1. Sensing
The system gathers information from its surroundings. It does this with sensors.
Examples:
- A distance sensor measures an obstacle in front of it.
- A light sensor detects whether the surroundings are bright or dark.
- A temperature sensor measures how warm the surroundings are.
- A button reports that the user has given a command.
2. Deciding
The control unit weighs up the information from the sensor according to the rules in the code.
If the distance is less than 15 centimetres
stop
turn right
Otherwise
go forward
An Arduino, a micro:bit or a similar microcontroller can run this decision part.
3. Movement or output
The system passes the result of the decision into the physical world.
- A motor turns.
- A servo moves to a certain angle.
- An LED lights up.
- A buzzer makes a sound.
- A warning appears on a screen.
We can show these three stages in a short form like this:
SENSE → DECIDE → MOVE
The basic parts of a robot
Control unit
This is the robot's decision centre. It takes information from the sensors, runs the program, and controls the outputs. The Arduino and the micro:bit are examples of boards used for this purpose.
Sensors
These let the robot understand its surroundings. Without sensors, a robot cannot notice changes in the outside world.
Actuators
These are the parts that turn electrical energy into movement, sound or another physical output. A motor, a servo, a buzzer and some light systems are examples of actuators.
Power source
This supplies the energy the system needs to work. A battery or a suitable low-voltage adapter can be used. The voltage and current of the power source must match the board and components being used.
Mechanical structure
The chassis, wheels, connecting parts, gears and supporting body make up the robot's physical structure.
Software
This is the set of instructions that decides what the robot does in each situation.
Is every automatic machine a robot?
No. A device working automatically does not always make it a robot.
For example, a simple lamp that only switches on and off at set times can be automatic. But if it does not gather information from its surroundings and change its behaviour based on that information, whether it counts as a robotic system is open to debate.
A robotic system usually has some or all of the following:
- Sensing the surroundings,
- Weighing up the data,
- Making a decision,
- Producing a physical output,
- Adapting to changing conditions.
Everyday examples of robotic systems
Robot vacuum
- It senses its surroundings with distance and collision sensors.
- It chooses a direction based on a map or movement rules.
- It moves by running its motors.
- Some models return to their station when the charge runs low.
Automatic door
- A motion sensor detects a person approaching.
- The control system decides that the door should open.
- A motor moves the door.
Smart irrigation system
- A soil-moisture sensor takes a reading.
- If the moisture is below a set limit, the system decides to water.
- A pump runs and the water begins to flow.
Line-following robot
- The light sensors underneath it detect the difference between dark and light surfaces.
- The control board adjusts the speed of the right and left motors.
- The robot corrects its direction so it stays on the line.
The difference between coding and robotics
Coding on its own can create a game, a calculation tool or a web page that runs on a screen. Robotics combines the code with physical components.
| Coding | Robotics |
|---|---|
| Mostly software | Includes software + electronics + mechanics |
| The output can be on a screen | The output can be physical movement or a measurement |
| A computer may be enough | A board, sensors, motors and power may be needed |
| Mistakes are mostly in the code | A fault can be in the code, the wiring, the power or the mechanics |
These two fields are not separate from each other. A good robotics project needs a clear algorithm and correct code.
Mini activity: design a smart night light
Goal: the LED lights up when the surroundings become dark, and switches off when they become bright.
The pieces to think through
- Input: the reading from the light sensor
- Decision: are the surroundings dark?
- Output: LED on or off
Pseudocode
Start
Measure the light level
If the light level is less than 30
turn the LED on
Otherwise
turn the LED off
Repeat the measurement
Questions to think about
- Is the value of 30 suitable for every setting?
- If the sensor keeps giving changing values, might the LED flicker?
- Which sensor could you add to make the system work not only at night, but when a person enters the room?
These questions show why testing and calibration matter in robotics.
Common mistakes
Thinking a robot is just a machine that moves
Even if a system does not move, it can still be a robotic system if it senses its surroundings, makes a decision and produces an output.
Not defining the problem before starting to code
"I am going to build a robot" is a very broad goal. "I am going to build a vehicle that stops 15 centimetres before an obstacle in front of it" is a clearer and more testable problem.
Overlooking the power source
The wrong voltage can damage the board or a component. Motors sometimes draw more current than the control board can supply. For this reason, a motor driver and a suitable power plan may be needed.
Looking for every fault in the code
In robotic systems, a problem does not come only from the code. A wire may be loose, a sensor connected the wrong way round, a battery weak, or a wheel jammed.
Safety note
The physical activities in this academy should only be carried out with safe, low voltage. Do not interfere with mains electricity, sockets or exposed wiring. Any work involving batteries, motors, soldering, cutting tools or hot surfaces needs adult supervision.
Review questions
- What are the three basic stages of a sense–decide–act system?
- Why is coding only one part of a complete robot?
- What makes a project goal testable?
- Which low-voltage safety habits belong in every electronics activity?
- Why is a failed first prototype useful evidence?
- What separates an educational project idea from a verified personal achievement?
Answers
- A sensor gathers input, a controller evaluates it with rules or a model, and an actuator produces a physical or visible output.
- A robot also depends on mechanics, power, electrical connections, sensors, actuators and safe physical design.
- It states an observable result, conditions and a measurable threshold rather than a vague wish.
- Disconnect power while wiring, check polarity and current limits, prevent shorts, use appropriate components and seek adult supervision when required.
- It reveals assumptions, boundary conditions and design weaknesses that can guide a controlled next change.
- A verified achievement has real build records, test evidence and approved media; an unbuilt idea must remain labelled as a proposed learning project.
Lesson summary
- Coding tells a system what to do with clear commands.
- Robotics brings together software, electronics and mechanics.
- A robotic system usually senses, decides and produces an output.
- Sensors gather information; the control unit decides; actuators carry out the result.
- For a successful project, the problem definition, safety, testing and debugging should be thought about together.
Check test
- What is coding for?
- What is the job of a sensor?
- Is a servo motor a sensor or an actuator?
- Explain a robot's "sense–decide–move" loop with an example.
- Why is not every automatic device counted as a robot?
- In a robotic system, which four different areas can a fault come from?
- In the smart night light, what are the input, the decision and the output?
Answers
- It tells a computer or control system the steps to follow and the decision rules to apply.
- It gathers data from the surroundings or from the system.
- It is an actuator; it produces a physical position based on the command it is given.
- For example, a distance sensor measures an obstacle, the board decides to stop if the distance is small, and the motors stop.
- Because a device that works only on a timer may not sense its surroundings or make decisions based on conditions.
- The code, the electronic wiring, the power source and the mechanical structure.
- The input is the light reading, the decision is whether the surroundings are dark, and the output is the LED switching on or off.
Source and verification note
For “What Are Robotics and Coding?”, verification focuses on whether the relationship between What will you learn in this lesson? and What is robotics? remains consistent across examples. The algorithms in this lesson are checked by tracing sample inputs by hand and comparing them with expected outputs. Pseudocode is used to make the reasoning sequence visible without tying it to one programming language.
End-of-lesson check
- How would you define What Are Robotics and Coding? in your own words?
- What is one normal use of the structure learned in this lesson?
- Which boundary or unexpected case would you test?
- How could you detect and correct one likely mistake?
- How would you adapt the same idea to another robotics or coding project?
End-of-lesson check — sample answers
- A good definition explains both the main idea and its purpose.
- The example should identify the input, the process and the resulting output.
- A boundary test can use the lowest or highest accepted value; an unexpected test can use missing or invalid input.
- Compare expected and actual results, change one thing at a time and repeat the test.
- Find the rule that remains the same, then adapt the steps to the new project’s input, tool and output.
Next lesson
What Is an Algorithm? — Learn how we set up the clear steps that a robot or a computer can carry out.