Robotics Basics
Lesson 1 / 15
Robo
What a robot is: sense, think, act
Sensors, controller, actuators; a robot vacuum as the example
Chapter 1. How a robot works
15 minutes
Python
4 questions
A robot is a machine that senses its surroundings, makes decisions and acts. Every robot — from a factory arm to a robot vacuum at home — runs on one loop:
┌──────────┐ ┌──────────┐ ┌──────────┐
│ SENSE │ ──▶ │ THINK │ ──▶ │ ACT │
│ sensors │ │controller│ │ motors │
└──────────┘ └──────────┘ └──────────┘
▲ │
└──────────── again ──────────────┘
| Part | Job | Examples |
|---|---|---|
| Sensor | measures the surroundings | distance (ultrasonic), light, temperature, camera, button |
| Controller | runs the program, decides | Arduino, Raspberry Pi, ESP32 |
| Actuator | moves or acts | motor, servo, speaker, light (LED) |
| Power | powers everything | battery |
How a robot vacuum "thinks"
It measures the distance to the obstacle ahead and decides:
LIMIT = 20 # cm — closer than this means turn
distances = [120, 80, 45, 18, 9, 60]
for d in distances:
action = "forward" if d > LIMIT else "turn"
print(f"{d} cm → {action}")
# Output: 120 cm → forward
# Output: 80 cm → forward
# Output: 45 cm → forward
# Output: 18 cm → turn
# Output: 9 cm → turn
# Output: 60 cm → forward
This is the robot's "brain": sensor value → condition → action. In a real robot this loop repeats dozens of times a second.
What robotics needs
- Programming — Python (simulation, AI, Raspberry Pi) and C++ (Arduino, fast control).
- Electronics basics — voltage, current, resistance, reading circuit diagrams.
- Maths — geometry and trigonometry (turning angles, distances).
💡 You don't need real hardware for this course: you'll drive a robot in a Python simulator. Moving the same logic onto an Arduino later is easy (lesson 5).
Practice Python
Pick the robot's speed from the distance: farther than 50 cm — "tez", 20–50 cm — "sekin", closer than 20 cm — "to'xta":
120 sm: tez
50 sm: sekin
35 sm: sekin
12 sm: to'xta
input() data
Write code and press "Run". Loading Python takes a few seconds the first time.
Show solution
def tezlik(masofa):
if masofa > 50:
return "tez"
if masofa >= 20:
return "sekin"
return "to'xta"
for m in [120, 50, 35, 12]:
print(f"{m} sm: {tezlik(m)}")