This is a long lesson that really does start from zero. You don’t need to know anything about electricity or programming first. We’ll climb one step at a time: from a single electric circuit to a robot’s brain, its eyes and ears, wheels and motors, control and learning by itself, all the way up to the advanced AI inside the newest robots. Then we finish with three projects you can really build at home or at school. Take it one level at a time. You can stop for a break halfway and come back later.
A robot is a machine that does three things over and over: it senses what is around it with sensors, thinks with a computer, then acts with motors. Our bodies do the same: our eyes sense, our brain thinks and our muscles act. A robot that follows fixed instructions is called an automatic robot, while a robot that uses AI to decide for itself based on what it sees is called a smart robot. Tap the dots on the robot to see what each part does.
Every robot starts with electricity. Think of water in a pipe. The battery is a pump that pushes the water, and this push is measured in volts. The amount of water flowing each second is called current, measured in amps. A resistor is like a narrow section of pipe: the narrower it is, the less water flows. Electricity can only flow when the circuit is a complete loop, from the positive terminal back to the negative terminal. If it is broken anywhere, the whole loop goes dead.
A breadboard is a board you push wires into without soldering; holes in the same row are connected inside. An LED has a long leg, which is positive, and a short leg, which is negative. A resistor has coloured bands that show its value. Jumper wires connect different points together. These are the first parts you’ll use in the projects at the end of this lesson.
Nerve cells use electricity too, but it comes from ions flowing through the cell membrane. The voltage is only about 0.07 volts, less than a twentieth of a single torch battery. The whole brain uses about as much power as a 20-watt light bulb. Find out more in Lesson 8.
The brain of a small robot is a microcontroller: a tiny computer on a palm-sized circuit board, such as an Arduino board or a micro:bit. It reads values from its sensors, follows its program, then gives orders to the motors. A program is a list of instructions in order. The computer faithfully carries them out one by one, and it does what we write, not what we meant. Try programming the robot to reach the star without hitting a wall.
The robot starts facing right
The “Repeat 3 times” command runs the next command three times. This is called a loop, one of the most important ideas in programming, and it makes programs much shorter.
Sequence Carry out the commands one at a time, from top to bottom. Condition If the sensor sees an obstacle, turn; otherwise, keep going. Loop Repeat over and over for as long as the robot is switched on. Almost every robot program in the world is built from these three things.
Beginners start by programming with blocks that you drag and snap together, for example in Scratch or the micro:bit’s MakeCode. Once you’re confident, you can type real code in C for Arduino, or in Python. The ideas behind them are the same in every language; only the way you write them is different.
Sensors turn things that happen in the real world into numbers: light, sound, distance, turning or pressure. A robot doesn’t see a room the way we do. It only sees a set of hundreds or thousands of distance numbers. See for yourself how a lidar sensor, which fires laser light all around it, sees the room. Tap inside the room to move the robot.
Tick “See what the robot sees” and the room disappears, leaving only the dots where the light hit. That is all the robot knows. The more beams it fires, the more detailed the picture, but the more it has to calculate.
Most robots that children build use two wheels, and each wheel has its own motor. If both wheels turn at the same speed, the robot goes straight. If the right wheel is faster, it turns left. And if one wheel turns forwards while the other turns backwards, it spins on the spot. This is called differential drive. Tanks and electric wheelchairs turn this way too. Try changing the speed of the two wheels and watch the path.
DC motor Spins continuously and fast, good for wheels. It is often connected to a gearbox that makes it slower but stronger. Servo motor Turns to an exact angle you tell it, such as 90 degrees. Good for robot arms and steering. Stepper motor Turns in small steps that can be counted. Used in 3D printers.
The pins of a microcontroller can only supply a tiny current, not enough to turn a motor, and connecting a motor straight to the board could damage it. So a motor driver board sits in between. It works like a water gate: the robot brain just says open or close, while the strong current from the battery flows through the driver board to the motor.
A line-following robot doesn’t know in advance which way the line will curve. It just measures how far it has drifted from the line right now, then steers back with a force that matches how far it has drifted. Then it measures again and corrects again, hundreds of times a second. This is called feedback control. The hard part is deciding how strongly to correct. Try adjusting this value, then let the car go.
Press “Let the car go”. The gold trail is the path the car really took, and the white line is the line it has to follow.
Up to Level 5, we wrote every rule for the robot ourselves. But some jobs are too hard to write rules for, such as walking on four legs. So researchers let the robot try by itself millions of times. Doing well earns points and making mistakes loses points, and the robot works out for itself which action in each position earns the most points overall. This is called reinforcement learning. Let this robot learn to find its way to the battery without falling into a hole.
The arrow in each square is what the robot currently thinks is the best move. The small number is the score it expects to get from that square.
At first the robot knows nothing, so it wanders about at random.
If a real robot had to fall over a million times, it would break before it learned to walk. So researchers train it in a simulated world inside a computer, where time can run a thousand times faster, then move the trained brain into the real robot. The tricky part is that the real world is never exactly like the simulation: floors are more slippery and motors are slower. So researchers deliberately vary the friction and weight in the simulation at random, so the robot isn’t caught off guard when it meets the real thing.
Toddlers don’t read a manual on walking. They try, fall, get up, and their brain gradually adjusts the nerve pathways that help them balance better. See how the brain changes with practice in Lesson 12. Toddlers fall far more often than you might think: one study found about 17 falls in every hour of play, yet within a few months they walk with ease. A robot learning in a simulated world often needs millions of tries.
Almost every new language and image AI uses a mechanism called attention. When it reads a word, it looks back at every word in the sentence and decides how much attention to pay to each one. This is the heart of the design called the transformer. Try tapping the word “it”, then change the last words of the sentence to see which word the AI pays attention to.
The attention weights in this picture are a made-up example to show the idea. A real AI has dozens of attention layers stacked up, and each layer has many heads that look for different kinds of relationships: for example, one head looks at who did something, and another looks at what it was done to.
The most exciting robot work may not be in factories at all, but very close to us: prosthetic hands that move in response to muscle signals, exoskeletons that help people with paralysis practise walking, and machines that read signals straight from the brain. Try controlling a prosthetic hand by squeezing your muscles. If you squeeze too hard, the egg will crack.
Sensors on the skin pick up the tiny electrical signals made when a muscle contracts. The harder you tense, the bigger the signal. The prosthetic hand turns the size of the signal into grip strength. Newer prosthetic hands have pressure sensors in the fingertips and use AI to recognise signal patterns from several muscles, so they can make more movements than just closing and opening.
By now we know every piece: electricity, the robot brain, sensors, motors and control. Let’s put them together into something real. The first project doesn’t need you to buy anything. The second and third use a basic robot kit you can buy from electronics shops. Always do them with an adult.
Use Teachable Machine, a free website that runs in your browser, to teach an AI to tell two or three things apart using your computer’s camera, such as a pencil, a rubber and an empty hand. This is the same thing you did on the cat-and-dog board in Lesson 15, but with real pictures.
This is the first robot that robotics students all over the world build, and it uses everything from Levels 1 to 5. Two infrared sensors look at the floor. A black line reflects little light and a white floor reflects a lot, so the robot knows which way it has drifted.
| Part | Quantity | Job |
|---|---|---|
| Arduino Uno board and USB cable | 1 | Robot brain |
| L298N motor driver board | 1 | Sends strong power from the battery to the motors when told to |
| Gear motors with wheels | 2 | Left and right wheels |
| Caster wheel or ball caster | 1 | Third wheel for balance |
| TCRT5000 infrared line sensor | 2 | Checks whether it can see the black line |
| Holder for four AA batteries, with an on/off switch | 1 | Power for the motors, about 6 volts |
| Chassis, jumper wires and black electrical tape | – | The car’s body, connecting wires, and for making the line on white paper |
Each button opens a Lazada search in a new tab and is not tied to any one shop. An adult should choose the shop and place the order.
Easiest: buy a complete kit. A line-follower car kit costs about 550 to 750 baht. Read the list of what is in the box before buying. Most kits have no HC-SR04 sensor and no long USB cable, and the battery holder may have no switch, so add those from the table below.
Or buy the parts one by one. About 400 to 700 baht in total, not counting batteries.
| Part | Approximate price | Check before you buy | Search |
|---|---|---|---|
| Arduino Uno R3 board with USB cable | 140 to 220 baht | Some shops sell the board without the cable, so check that a USB cable is included | Lazada |
| L298N motor driver board | 40 to 75 baht | A red board with a black heatsink | Lazada |
| Two-wheel car chassis with motors | 90 to 150 baht | It must come with 2 yellow gear motors, 2 wheels and a free-spinning caster, not just a bare acrylic plate | Lazada |
| 2 TCRT5000 sensor modules | 20 to 35 baht each | Choose the module with a small circuit board and 3 pins, not the bare sensor that costs a few baht, and not the 5-channel version | Lazada |
| 4 x AA battery holder with a switch | 20 to 45 baht | It must have an on/off switch so you can cut the power at once | Lazada |
| Jumper wires | 15 to 30 baht | Get both male-to-female and male-to-male | Lazada |
| HC-SR04 ultrasonic sensor, for project 3 in Lesson 16 | 30 to 60 baht | You only need it for the obstacle-avoider project | Lazada |
| 3-metre USB cable, for the AI Driver project in Lesson 17 | 20 to 45 baht | Check the socket on your board first: most use Type B, but some use Type-C | Lazada |
Approximate prices from Lazada search pages in September 2026. Shops and prices change all the time. Choose shops with good reviews that ship from within Thailand. This website receives no payment from any shop or from Lazada.
| From | To |
|---|---|
| Left sensor, OUT pin | Arduino D2 |
| Right sensor, OUT pin | Arduino D3 |
| Both sensors, VCC and GND pins | Arduino 5V and GND |
| L298N pins IN1 IN2 IN3 IN4 | Arduino D5 D6 D9 D10 |
| Left motor and right motor | L298N OUT1 OUT2 and OUT3 OUT4 |
| Battery holder, positive | L298N 12V terminal |
| Battery holder, negative | L298N GND, and also connect it to the Arduino’s GND |
The grounds of all the boards must be connected together. If you forget, the board can’t control the motors. This is the most common mistake beginners make. Leave the jumpers on the driver board’s ENA/ENB pins as they came from the factory.
// Line follower: two IR sensors straddle a black line const int SL = 2, SR = 3; // left and right sensors const int L1 = 5, L2 = 6, R1 = 9, R2 = 10; // motor driver inputs void drive(int left, int right) { // speeds from -255 to 255 analogWrite(L1, left > 0 ? left : 0); analogWrite(L2, left < 0 ? -left : 0); analogWrite(R1, right > 0 ? right : 0); analogWrite(R2, right < 0 ? -right : 0); } void setup() { pinMode(SL, INPUT); pinMode(SR, INPUT); pinMode(L1, OUTPUT); pinMode(L2, OUTPUT); pinMode(R1, OUTPUT); pinMode(R2, OUTPUT); } void loop() { bool left = digitalRead(SL) == HIGH; // HIGH = sensor sees black bool right = digitalRead(SR) == HIGH; if (!left && !right) drive(150, 150); // line is between: go straight else if (left && !right) drive(0, 160); // drifted right: turn left else if (!left && right) drive(160, 0); // drifted left: turn right else drive(0, 0); // both black: stop }
Use the same car base from Project 2, but swap its eyes from floor sensors to an HC-SR04 ultrasonic sensor. It sends out a sound too high-pitched for our ears to hear, then times how long the echo takes to come back, just as bats find their way in the dark. Sound travels at about 343 metres per second, so we can work out the distance from the time.
| HC-SR04 pin | To |
|---|---|
| VCC | Arduino 5V |
| TRIG | Arduino D7 |
| ECHO | Arduino D8 |
| GND | Arduino GND |
// Obstacle avoider: keep drive() and the motor pins from project 2, // then replace setup() and loop() with these const int TRIG = 7, ECHO = 8; long distanceCm() { digitalWrite(TRIG, LOW); delayMicroseconds(2); digitalWrite(TRIG, HIGH); delayMicroseconds(10); // send a short ping digitalWrite(TRIG, LOW); long us = pulseIn(ECHO, HIGH, 30000); // wait for the echo if (us == 0) return 999; // nothing in range return us * 0.0343 / 2; // there and back, so halve it } void setup() { pinMode(TRIG, OUTPUT); pinMode(ECHO, INPUT); pinMode(L1, OUTPUT); pinMode(L2, OUTPUT); pinMode(R1, OUTPUT); pinMode(R2, OUTPUT); } void loop() { if (distanceCm() < 20) { // something within 20 cm drive(0, 0); delay(200); drive(-140, -140); delay(300); // back up drive(150, -150); delay(350); // spin to the right } else { drive(150, 150); // path is clear } delay(50); }
The stronger and smarter robots get, the more important safety becomes. Factory robots are always fenced off and have a big red emergency stop button. Robots that work near people must be able to sense when they bump into something and stop immediately. And every time a robot makes a mistake, a person must be responsible.
Teams of Thai university students have won the world championship in the RoboCup rescue robot competition several times, and many schools in Thailand have robotics clubs. You can get started with a club at school or a science camp during the school holidays.
Read the name of each part, then choose whether it is a sensor, the brain, an actuator or a power source. You have 45 seconds.
They run from Level 1 words you’ll use from day one up to Level 3 words that robotics researchers use with each other. Use self-test mode to revise before you take the quiz.
Every question from this lesson is in the Body 101 arena. Race the clock, duel someone at home, play as a team, beat the bosses, or practise with no timer at all.