Body 101 · Special Lesson · Lesson 16 · Ages 10 to 13

Advanced AI and Robots From Zero to Building Your Own

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.

Four kinds of robot on a lab bench: on the left a white four-wheeled robot with a robotic arm and a round camera head, in the middle a round robot vacuum, on the right a four-legged robot dog, with a four-rotor drone hovering above
Level 0 · BasicsSense, think, act

What is a robot?

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.

8 kinds of robot around us

A round robot vacuum on a wooden floor in a living room at dusk, projecting a glowing blue three-dimensional floor plan of the home above it, with dashed lines showing where it has already cleaned and one room highlighted in gold
The robot vacuum and the map in its headNewer robot vacuums build a map of the room by themselves as they go, remember where they have already cleaned, and find their own way back to recharge. It is a robot that senses, thinks and acts: all three.
A white six-rotor spraying drone flying low over green rice paddies at sunset, spraying a fine mist onto the rice, with coconut palms, a small farmhouse and hills in the distance
A farm drone over a rice fieldIn Thailand, drones are being used more and more to spray fertiliser and survey rice fields. The drone flies along a planned route, uses satellites to know where it is, and uses a camera to see which parts of the rice crop need fertiliser.
A white breadboard with a glowing red LED, a colour-banded resistor, blue and yellow jumper wires, and red and black leads running to a holder with three AA batteries
Level 1 · ElectricityOur first circuit

Electricity is energy that flows in a loop

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.

Try it: why do we need a resistor?

0
Current (milliamps)
–
LED status

Ohm’s law Current equals voltage divided by resistance. The LED uses up about 2 volts, and the rest is dropped across the resistor. A typical LED can handle about 20 milliamps. Without a resistor to hold it back, the current shoots up until the LED burns out.

Your first kit: parts to know

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.

Electricity in our bodies

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.

Safety firstOnly experiment with torch batteries and small batteries. Never touch mains electricity. It is dozens of times higher in voltage than a torch battery and can kill. Never connect a battery’s positive and negative terminals directly with nothing in between, because the battery can get extremely hot and may catch fire.
A small microcontroller board with a grid of tiny glowing lights, connected by a USB cable to a laptop whose screen shows brightly coloured coding blocks snapped together like jigsaw pieces
Level 2 · Robot brainMicrocontrollers and programs

A robot’s brain follows instructions one line at a time

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.

Add commands, then press Run

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.

Three big ideas in programming

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.

Start with blocks, then type code

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.

A round robot on a darkened living-room floor sending thin blue beams out in every direction; pink dots line the edges of the walls, door, table, sofa and a box, tracing the outline of the room
Level 3 · SensingThe robot’s eyes and ears

How does a robot know what is around it?

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.

–
Nearest obstacle (cm)
–
Direction on the map

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.

Common sensors

Parts of a two-wheeled robot car floating apart: two rubber wheels on yellow gear motors, a clear acrylic base plate, a red motor driver board with a black heatsink, a battery holder, and a metal ball caster with its screws
Level 4 · MovementMotors, wheels and joints

Two wheels can turn without a steering wheel

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.

Three kinds of motor

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.

Why do we need a motor driver board?

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 small yellow-wheeled robot car following a black tape line on white paper; two sensors under its front glow red on either side of the line, and a golden trail curves back along the path it has driven
Level 5 · ControlFeedback loops

Measure, correct, measure again, over and over

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.

–
Average drift from the line (mm)
–
Times it swerved across the line

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.

Our bodies use feedback loops too When you pick up a glass of water, your eyes keep telling your brain how far your hand still is from the glass, and the cerebellum keeps adjusting your muscle strength bit by bit. When someone’s cerebellum is damaged, their hand wobbles back and forth past the target as they reach out, a bit like the car that corrects too strongly in this simulation. Doctors call this an intention tremor.
A four-legged robot dog walking across a practice floor, with faint copies of itself behind it in earlier poses, from lying tipped over, to staggering up, to walking steadily at the front
Level 6 · LearningTrial and error with rewards

Robots that teach themselves to walk

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.

0
Rounds trained
–
Reached the goal in the last 20 rounds

At first the robot knows nothing, so it wanders about at random.

Scoring rules Reaching the battery earns 10 points, falling into a hole loses 10 points, and every step loses 0.1 points. So the robot learns to get there by the shortest and safest route. Sometimes it also tries a new route at random, so it doesn’t get stuck on an old route that may not be the best.

Practise in a simulated world first

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.

Just like a toddler learning to walk

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.

A white robotic arm reaching towards a red apple on a table beside a woven basket, with thin golden threads of light linking the gripper, the apple and the basket
Level 7 · Advanced AIAttention, foundation models and AI with a body

How do new AIs understand meaning?

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.

6 big steps forward in advanced AI

A robotic prosthetic hand on a metal stand gently holding a white egg between its thumb and first finger; the fingertips have glowing blue sensor pads and wires are visible inside the forearm
Level 8 · The bodyA brain doctor’s view

Robots that help our bodies

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.

Robots and medical technology

An operating theatre with a four-armed surgical robot hanging over an empty operating table covered in a blue sheet; on the right is the surgeon’s console with its viewing eyepieces, with nobody sitting at it
Surgical robotsThe surgeon sits at a control console and controls every movement of the robotic arms. The robot doesn’t make decisions by itself, but it helps filter out hand tremor and scales movements down to make them more precise, so operations can be done through small holes.
A powered leg exoskeleton with motors at the hip and knee joints, padded straps and foot plates, standing on a metal stand in a physiotherapy room next to a pair of parallel walking bars
Exoskeletons for walking practiceUsed in rehabilitation centres together with physiotherapists, they help some patients who have had a stroke or a spinal cord injury practise stepping over and over, more often. They are a training tool, not a cure.
A child’s two hands plugging wires into a blue microcontroller board fixed to the wooden base of a robot car, with yellow wheels, a battery holder, colourful wires, screws and a screwdriver on the table around it
Level 9 · BuildThree projects, from easy to hard

Build it yourself

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.

Project 1EasyNothing to buy

Build your own image-sorting AI

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.

  1. Ask an adult to open teachablemachine.withgoogle.com and choose an image project.
  2. Name the first class “Pencil” and the second “Rubber”, then add a third class called “Nothing”.
  3. Press the camera button for each class and turn the object to lots of different angles. Collect at least 50 pictures per class: close up and far away, in bright light and in the dark.
  4. Press the Train button and wait less than a minute. Don’t close the window while it is training.
  5. Hold an object in front of the camera and watch the confidence bar for each class. Try holding something you never taught it, such as scissors, and see what the AI says.
  6. Try an experiment to see bias: teach it only with yellow pencils, then hold up a black pencil. Can the AI still recognise it? If not, add more varied examples and train it again.
What you learn Varied training data matters more than lots of it, and AI can answer confidently even about things it has never seen. This links to training data and bias in Lesson 15. The camera pictures are processed on your own computer, but you still shouldn’t use your own face or your friends’ faces as training data.
Project 2MediumNeeds an adult’s help

A robot that follows a black line

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.

A finished line-following robot on a clear acrylic chassis, with a blue microcontroller board, a red motor driver board with a heatsink, a holder of four AA batteries, two yellow wheels, and two sensors at the front glowing blue just above a black tape line on white paper
What the finished robot looks likeA two-wheeled chassis, the robot brain board, the motor driver board, a battery holder and two sensors at the front, about one centimetre above the floor, one on each side of the black line.

Parts

PartQuantityJob
Arduino Uno board and USB cable1Robot brain
L298N motor driver board1Sends strong power from the battery to the motors when told to
Gear motors with wheels2Left and right wheels
Caster wheel or ball caster1Third wheel for balance
TCRT5000 infrared line sensor2Checks whether it can see the black line
Holder for four AA batteries, with an on/off switch1Power 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
Buying the parts on Lazada

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.

Search Lazada for kits

Or buy the parts one by one. About 400 to 700 baht in total, not counting batteries.

PartApproximate priceCheck before you buySearch
Arduino Uno R3 board with USB cable140 to 220 bahtSome shops sell the board without the cable, so check that a USB cable is includedLazada
L298N motor driver board40 to 75 bahtA red board with a black heatsinkLazada
Two-wheel car chassis with motors90 to 150 bahtIt must come with 2 yellow gear motors, 2 wheels and a free-spinning caster, not just a bare acrylic plateLazada
2 TCRT5000 sensor modules20 to 35 baht eachChoose the module with a small circuit board and 3 pins, not the bare sensor that costs a few baht, and not the 5-channel versionLazada
4 x AA battery holder with a switch20 to 45 bahtIt must have an on/off switch so you can cut the power at onceLazada
Jumper wires15 to 30 bahtGet both male-to-female and male-to-maleLazada
HC-SR04 ultrasonic sensor, for project 3 in Lesson 1630 to 60 bahtYou only need it for the obstacle-avoider projectLazada
3-metre USB cable, for the AI Driver project in Lesson 1720 to 45 bahtCheck the socket on your board first: most use Type B, but some use Type-CLazada

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.

Wiring

FromTo
Left sensor, OUT pinArduino D2
Right sensor, OUT pinArduino D3
Both sensors, VCC and GND pinsArduino 5V and GND
L298N pins IN1 IN2 IN3 IN4Arduino D5 D6 D9 D10
Left motor and right motorL298N OUT1 OUT2 and OUT3 OUT4
Battery holder, positiveL298N 12V terminal
Battery holder, negativeL298N 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.

The program

// 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
}
  1. Install the Arduino IDE on your computer, plug the USB cable into the board, and choose Arduino Uno as the board type.
  2. Type or copy the program above and press the Upload button. While you do this, keep the wheels lifted off the ground.
  3. Stick black tape in a curving loop on a large sheet of white paper. The line should be about 2 centimetres wide, with gentle curves and no sharp corners.
  4. Turn the screw on each sensor until the sensor’s light is on over the white floor and off over the black line, or the other way round, depending on the model.
  5. Place the robot so the line is between the two sensors, switch on the battery holder, and watch it go.
TroubleshootingIf the robot turns away from the line instead of towards it, swap HIGH for LOW in the two lines that read the sensors, because some sensor models give the opposite value. If a wheel spins backwards, swap the wires for that motor. If the car wobbles a lot on bends, lower the speed numbers, just like lowering the correction strength in Level 5.
Project 3ChallengingBuilds on Project 2

An obstacle-avoiding robot

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 pinTo
VCCArduino 5V
TRIGArduino D7
ECHOArduino D8
GNDArduino 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);
}
  1. Mount the sensor on the front of the car, with its two “eyes” facing straight ahead.
  2. Before fitting the wheels, open the Serial Monitor window and print out the distanceCm value. Move your hand closer and further away to check the distance is right.
  3. Upload the full program, put the robot in a room with cardboard boxes as walls, and watch it find its way.
  4. Try changing the number 20 to 10 or 40 and see whether the robot becomes more or less careful.
Next steps Combine the two projects so the robot follows a line and stops when something is in the way. Or go further with a single-board computer that has a camera, and add the image-sorting AI from Project 1 so the robot follows the signs it sees. That is a robot that senses, thinks and acts, completing the whole loop just like real robots.
A red mushroom-shaped emergency stop button on a yellow panel in the foreground, with an orange industrial robot arm working behind a yellow mesh safety fence in the background
Level 10 · ResponsibilitySafety, ethics and careers

A good robot must be safe before it is smart

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.

Robot safety principles

Questions society must answer together

Careers in the world of robots

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.

Game: what does this part do?

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.

045 seconds
Press to start the game

RememberRobots are not here to replace people. They are here to do jobs that are dangerous, repetitive or too fiddly for human hands. Decisions that affect people’s lives, compassion and responsibility are still people’s work. People who understand both robots and people are the people the future needs.
Robot parts laid out neatly on a dark surface: two yellow gear motors, a blue servo, two wheels, a battery holder, a microcontroller board, an ultrasonic sensor with two round transducers, an infrared sensor, a camera module, colourful jumper wires, screws and a metal gripper claw
GlossaryFrom beginner to upper-intermediate

24 robotics terms worth knowing

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.

Review12 questions

Test yourself

Correct: 0 of 12

Fancy a game on this lesson?

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.