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.

30 Min.

Diese Seite ist noch nicht übersetzt und wird deshalb auf Englisch angezeigt.

Erklärvideo, 18 s
Jeder Roboter erledigt immer wieder drei Aufgaben: wahrnehmen, entscheiden, handeln.Wahrnehmen: Der Stoßfänger eines Saugroboters spürt, dass er an ein Stuhlbein gestoßen ist.Entscheiden: Sein Programm bemerkt den Stoß und wählt: ein Stück zurück, dann drehen.Handeln: Die Radmotoren führen es aus. Dann beginnt die Schleife neu, viele Male pro Sekunde.Ein ferngesteuertes Auto bewegt sich auch, aber du entscheidest. Ein Roboter schließt die Schleife selbst.

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:

JobQuestionParts 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.

SensesDecides itselfActs
remote-control carnono (you do)yes
washing machinea little (water level)follows a fixed programmeyes
robot vacuumyesyesyes

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.

distance between looks=30 cm/s15 per second=2 cm\text{distance between looks} = \frac{30\ \text{cm/s}}{15\ \text{per second}} = 2\ \text{cm}

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.

RobotSensesDecidesActs
robot lawn mowera signal wire around the lawn, bump sensors, a tilt sensorstay inside the wire, turn at the edge, stop the blade when liftedwheel motors, blade motor
warehouse robotcodes on the floor, distance sensorsfollow the route, stop for peoplewheel motors, a lift
Mars rovercameras, wheel turns, tiltdrive to the next point chosen from Earth, avoid rocks on the waysix wheel motors, arm
your Obstabotdistance to the wall in frontdrive, back up, or turntwo 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:

PartJob in the loopLessons
ESP32-C3 SuperMini, a microcontroller board the size of a stampdecide4, 5
Breadboard and jumper wiresconnect everything without soldering2, 3
LED and resistorsyour first “act”, and a way to see what the program is doing2, 4, 6
Push buttonyour first sensor4, 5, 16
Two continuous-rotation servosact: turn the wheels8, 9
HC-SR04 ultrasonic sensorsense: how far is the wall?11
USB power bankpower for all of it10, 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

  1. What is a robot, really? (this lesson, free)
  2. Your first circuit: an LED you calculate before you build
  3. Tools and a safe workbench: multimeter, pinout and soldering
  4. Your first program: blink, and a button that does something
  5. Buttons and inputs: pull-ups, bouncing and a start button
  6. Light, sound and status: LED brightness, a buzzer and blink codes
  7. Analogue sensors: reading a knob and a light sensor
  8. Making things move: servos
  9. Motors and motor drivers: why a pin cannot drive a wheel
  10. Power for robots: batteries, regulators and a common ground
  11. Seeing the world: measuring distance with sound
  12. Your robot drives itself
  13. Making it your own: body, mounts and tidy wiring
  14. Following a line with infrared sensors
  15. Driving from your phone over Wi-Fi
  16. Final project: debug, test and finish your robot