Lili's Workshop
Robot no. 3 · Exploration mission

The Roller

A robot that drives by itself, sees obstacles and goes around them, like a robot vacuum.

Difficulty★★★☆
Time2 afternoons
Budget≈ €50
You'll learnMotors, decisions

How does it work?

A robot that decides where to go all by itself. A real explorer at last!

Lili waving
Hi there!

Have you ever watched a robot vacuum? It zooms along, stops just before the sofa, thinks, and heads off somewhere else. The Roller does the same: it looks ahead, and if there's an obstacle, it turns its head left and right to pick the clearest way.

The eyes

The ultrasonic sensor

You already know it! It measures the distance to the next obstacle, like a bat.

The neck

The servo motor

It turns the Roller's head to look left, then right, before choosing.

The brain

The Arduino

It reads what the eyes see and decides: straight on, reverse, or turn.

The legs

The motors and the L298N

Two motors, one per wheel. To turn, one wheel goes forward while the other goes backward!

IF the way is clear → go forward. OTHERWISE → back up, look, turn… and off again!

Lili explaining with a tablet
Let me explain

The Arduino is too weak to spin the motors by itself. So it gives orders to the L298N, the boss of the muscles, which takes energy from the batteries. It's like a captain giving orders to the rowers!

Click the floor to drop a cushion, click a piece of furniture to remove it.

Room explored0 %
Bumps0
Time0 s

Test the Roller in a bedroom

From 0 (stopped) to 255 (full speed).
Closer than this, the Roller stops.
The longer it is, the more it turns.

The Roller is starting…

Lili has an idea
Experiment

Set STOP_DISTANCE to 5 cm and count the bumps. Then try 30 cm. These three settings are exactly the same as in the real program: find the best ones here before trying them for real!

Shopping list

Tick each thing once it's on your table. Lili remembers your ticks.

0 / 0 found

Electronics and chassis

    Small bits

      Tip

      Lots of chassis kits come with a 4-battery holder. Get the 6-battery one anyway: the L298N "eats" a bit of energy, and with 4 batteries the Roller would be sluggish.

      Lili with her arms crossed
      Check the motors

      Make sure the wires are already soldered onto the yellow motors. If not, ask a grown-up to solder them before you start.

      Tools: Phillips screwdriver, small pliers, hot glue gun, computer with Arduino IDE. Prices are rough guides. The Amazon buttons open a search: pick a well-rated seller and compare with the "Check" line.

      Building, step by step

      One step at a time. Click "Done!" when you've finished.

      0 / 0 steps
      1

      Build the chassis

      40 minutes
      Chassis kitScrewdriver
      1. Peel the protective paper off the plate (the most satisfying moment!).
      2. Fix the two yellow motors under the plate with their little brackets, mirrored: shafts facing out, wires facing in.
      3. Push a wheel onto each shaft. They should spin without rubbing.
      4. Screw the caster wheel at the front with the spacers.
      5. Put the Roller on the floor: it should stand on its 3 wheels without wobbling.
      Tip

      Every kit is a little different: keep its instructions next to you. If a hole doesn't line up, don't worry, a good blob of hot glue works too.

      2

      Fit the brain and the batteries

      20 minutes
      1. Stick the battery holder under the plate, near the wheels: the weight helps the Roller grip the floor.
      2. Fix the L298N module at the back, heatsink facing up.
      3. Fix the Arduino in the middle (screws or double-sided tape), USB socket facing back so it's easy to plug in.
      4. Stick the mini breadboard at the front, next to where the head will go.
      What do you think?

      Why put the batteries near the wheels, not right at the front? Hint: try pushing a shopping trolley that's heavy at the front.

      3

      Wiring

      30 minutes · switch OFF!

      On the L298N, the wires screw into little terminals. Loosen the screw, slide the wire in, tighten. Also remove the two small black jumpers on ENA and ENB: the Arduino will choose the speed.

      PartWire or terminalGoes to
      Battery holderred (+)L298N "12V"
      Battery holderblack (−)L298N "GND"
      L298NGNDArduino GND (very important!)
      L298N5VArduino 5V
      Left motor2 wiresL298N OUT1 and OUT2
      Right motor2 wiresL298N OUT3 and OUT4
      L298NENA / IN1 / IN2D5 / D2 / D4
      L298NIN3 / IN4 / ENBD7 / D8 / D6
      Servo motorbrown / red / orangeGND / 5V / D10
      HC-SR04 sensorVCC / Trig / Echo / GND5V / D12 / D11 / GND
      Golden rule

      Wire everything with the battery switch OFF. And while the USB cable is plugged into the computer, the switch stays OFF too. Ask a grown-up to check before switching on.

      The magic wire

      The wire between the L298N's GND and the Arduino's GND is the one people forget most… and without it, nothing works! Both need to speak the same "electric language".

      4

      First test: the wheels

      15 minutes · wheels in the air
      1. Rest the Roller on a box or a book, wheels off the ground, so it can't run away.
      2. Connect the Arduino to the computer and upload this program.
      3. Unplug the USB cable, then flip the switch ON.
      motor_test.ino
      1. Both wheels should spin forward, then backward, then the Roller turns left.
      A wheel spinning backwards?

      That's very common! Switch OFF, then swap that motor's two wires on the L298N (OUT1 with OUT2, or OUT3 with OUT4).

      5

      The looking head

      25 minutes
      SG90 servoSensor bracketHC-SR04Hot glue
      1. Glue the servo at the front of the Roller, shaft facing up.
      2. Upload this program. With CENTER_ONLY = true, the head turns straight and stays still.
      head_test.ino
      1. Now fix the bracket onto the shaft, with the eyes looking straight ahead, then clip the sensor into it.
      2. Change CENTER_ONLY to false, upload, and open Tools → Serial Monitor. The head looks left, ahead, right, and writes the distances.
      Left or right?

      When the program says "160", the head should look left. If it looks right, your servo is mounted the other way round: you'll swap the values of LOOK_LEFT and LOOK_RIGHT in the next step.

      6

      The Roller's big program

      15 minutes

      Here's the complete brain. Look at the loop() function: it's the Roller's rule written in Arduino language, with an if and an else (otherwise).

      roller.ino
      Before putting it down

      Unplug the USB, put the Roller on the floor, and only then flip the switch ON. It waits 2 seconds, then off it goes!

      7

      First journey and tuning

      As long as it takes!

      Let the Roller loose in your room and watch. Then change only one setting at a time, just like in the simulator.

      It bumps into furniture

      Raise STOP_DISTANCE (25, 30…) or lower SPEED: it needs more room to brake.

      It hesitates and goes round in circles

      Raise TURN_TIME so it turns more decisively after looking.

      It doesn't see chair legs

      That's normal: they're too thin for ultrasound. Real robot vacuums have a bumper for that too!

      Logbook

      Time 2 minutes and write down how far the Roller got with each setting. That's how engineers test real robot vacuums!

      Lili ready for adventure
      Mission accomplished

      Your Roller explores on its own!

      You've built an autonomous robot: it senses, decides and moves without anyone steering it. It's the same idea as robot vacuums and the rovers on Mars.

      • Challenge 1: add a small buzzer that goes "beep" when the Roller sees an obstacle.
      • Challenge 2: invent a victory dance: three spins on the spot when it starts!
      • Challenge 3: in the simulator, find settings that explore 80 % of the room with zero bumps.
      Well done!