What is a robot, really?
Sense, decide, act: the loop inside every robot from a vacuum cleaner to a Mars rover, and the parts you will use to build your own.
Esta página aún no está traducida, por eso se muestra en inglés.
Not a metal person
When people hear “robot”, they picture a metal person. Most real robots look nothing like that: a vacuum cleaner, a lawn mower, a warehouse cart, a car that keeps its lane, a drone that holds its position in the wind.
What makes them robots is not their shape. It is that they do three jobs, over and over, on their own:
| Job | Question | Parts that do it |
|---|---|---|
| Sense | “What is around me? What is happening?” | sensors: distance, light, touch, camera, encoders on the wheels |
| Decide | “What should I do now?” | a microcontroller running a program |
| Act | “Do it.” | motors, servos, lights, speakers |
Then the loop starts again, often 10 to 1000 times per second.
A machine is not always a robot
A washing machine runs a programme, but it does not watch the world and change its plan. A toy car with a remote control moves, but you decide, not the car. A robot closes the loop itself.
| Senses | Decides itself | Acts | |
|---|---|---|---|
| remote-control car | no | no (you do) | yes |
| washing machine | a little (water level) | follows a fixed programme | yes |
| robot vacuum | yes | yes | yes |
Open loop and closed loop
Engineers have two names for this difference.
An open loop machine does its steps without checking the result. A toaster with a timer heats for two minutes, whether the bread is pale or already black. If something changes (thicker bread, a colder kitchen), it cannot notice.
A closed loop machine measures the result and corrects itself. That measurement, going back into the decision, is called feedback. A robot is a closed loop machine: it acts, senses what happened, and decides again.
Closed loop wins whenever the world is not exactly as planned. And the world is never exactly as planned: floors are slippery, batteries get weaker, one wheel is a little faster than the other.
How fast must the loop be?
A robot only knows what its sensors told it at the last look. Between two looks it is driving blind. So the question is: how far does it move between two looks?
Here is a worked example. Say a small robot drives at 30 cm per second, and its loop runs 15 times per second.
Two centimetres of blind driving is fine. If the robot sees a wall at 15 cm, it has plenty of time to react.
This is also why the decide step must be quick. If the program stops to wait for something (a button, a long calculation), the whole loop stops, and the robot drives blind for that long.
Sensors are never perfect
A sensor gives a number. That number is never exactly the truth.
- A distance sensor may give 20.1 cm, then 19.8 cm, then 20.3 cm for a wall that did not move. This small wobble is called noise.
- Sometimes it gives a wild value, like 250 cm, because the sound bounced somewhere strange.
- Sometimes it gives nothing at all, because no echo came back.
A good robot program expects all three. In lesson 11 you will see each of them on your own screen, and in lesson 12 your robot will take the middle of the last three readings, so one wild value cannot fool it.
More robots, same loop
Look at these with the three questions in mind.
| Robot | Senses | Decides | Acts |
|---|---|---|---|
| robot lawn mower | a signal wire around the lawn, bump sensors, a tilt sensor | stay inside the wire, turn at the edge, stop the blade when lifted | wheel motors, blade motor |
| warehouse robot | codes on the floor, distance sensors | follow the route, stop for people | wheel motors, a lift |
| Mars rover | cameras, wheel turns, tilt | drive to the next point chosen from Earth, avoid rocks on the way | six wheel motors, arm |
| your Obstabot | distance to the wall in front | drive, back up, or turn | two wheel servos |
The Mars rover is interesting. A radio message between Earth and Mars takes several minutes, and on some days around twenty, depending on where the two planets are. Nobody can steer it like a remote-control car. It must close the small loops (do not drive into that rock) by itself. Your robot is the same idea, at a much smaller size.
The parts of your first robot
By the end of this course you will build a small robot that drives forward, sees a wall coming and turns away by itself. Here is what each part does:
| Part | Job in the loop | Lessons |
|---|---|---|
| ESP32-C3 SuperMini, a microcontroller board the size of a stamp | decide | 4, 5 |
| Breadboard and jumper wires | connect everything without soldering | 2, 3 |
| LED and resistors | your first “act”, and a way to see what the program is doing | 2, 4, 6 |
| Push button | your first sensor | 4, 5, 16 |
| Two continuous-rotation servos | act: turn the wheels | 8, 9 |
| HC-SR04 ultrasonic sensor | sense: how far is the wall? | 11 |
| USB power bank | power for all of it | 10, 12 |
A few lessons add small optional parts: a piezo buzzer (lesson 6), a potentiometer and a light sensor (lesson 7), and two infrared line sensors (lesson 14). Each of those lessons lists what it needs, and you can follow along without them.
You also need a computer (Windows, macOS or Linux) where you can install the free program Thonny. That is where you will write your code from lesson 4 on.
Why these parts?
There are many ways to build a first robot. We picked parts that are cheap, easy to replace, and forgiving for beginners.
- ESP32-C3 SuperMini with MicroPython. You write the program in Python, a language that reads almost like English. You can type a line and the board answers at once, so you learn by trying. If you break the board, a new one costs about as much as a pizza.
- Continuous-rotation servos instead of bare motors. A bare motor needs an extra board (a motor driver) between it and the microcontroller. A servo has that driver built in, so three wires are enough. Lesson 9 explains what is inside and why a pin alone could never drive a motor.
- An ultrasonic sensor. It measures distance with sound, like a bat. It is cheap, works in the dark, and its numbers are easy to understand.
- A USB power bank. It has its own protection electronics inside, so it is the safest battery for a first robot. Lesson 10 is about power, and why loose lithium cells need more care.
How the course works
Every lesson has the same rhythm:
- an idea, explained with a picture you can keep in your head,
- a prediction: you write down what you think will happen before you try it (this is the most important habit in all of engineering),
- something to try with real parts or in the interactive widget,
- the typical mistakes, so you do not lose an evening on them,
- homework with a bonus question for the curious,
- a short check yourself quiz at the end.
Why predict first? Because a wrong guess teaches you more than a right answer you only read. When your prediction and the real result disagree, you have found exactly the thing you did not understand yet. Engineers do this all day: “I expect 9 mA. The meter shows 0. So something is not connected.”
Check yourself
What the full course covers
- What is a robot, really? (this lesson, free)
- Your first circuit: an LED you calculate before you build
- Tools and a safe workbench: multimeter, pinout and soldering
- Your first program: blink, and a button that does something
- Buttons and inputs: pull-ups, bouncing and a start button
- Light, sound and status: LED brightness, a buzzer and blink codes
- Analogue sensors: reading a knob and a light sensor
- Making things move: servos
- Motors and motor drivers: why a pin cannot drive a wheel
- Power for robots: batteries, regulators and a common ground
- Seeing the world: measuring distance with sound
- Your robot drives itself
- Making it your own: body, mounts and tidy wiring
- Following a line with infrared sensors
- Driving from your phone over Wi-Fi
- Final project: debug, test and finish your robot