Challenge 1
Find the offset that walks best. Try 90, 180 and 270 degrees of head start, and report which gave the steadiest walk on your build. Watch the body height rather than the legs.
EV3 Robotics›Level 2 · Intermediate›Lesson 9
Level 2 · Lesson 9 · EV3-L02-0960 minutes · Ages 9–16 · Model: Dual Motor Hexapod
The Dual Motor Hexapod: six legs, three on each side, with a Large Motor driving each side independently.
Lesson 6 said a pair of motors must stay in step. Lesson 11 said they should disagree about speed when you want to turn. This model needs a third thing, and it is the one nobody expects.
Same speed, same direction — and permanently half a cycle apart. Match them exactly and the hexapod lifts all six legs at once and falls on its face.
Watch any insect walk. Ants, beetles, cockroaches — all six-legged, and all using the same pattern, which is one of the most reliable things in the animal kingdom.

It is called the alternating tripod gait. At every moment, three legs are on the ground and three are swinging forward — and the three on the ground are the front and back on one side and the middle leg on the other.
Three points make a stable base, always. So an insect walking this way is standing on a tripod at every instant of the stride and never has to balance at all. It can stop dead mid-step and it will not topple.
And the two tripods are exactly out of phase: when one set is down the other is up, and half a cycle later they swap. The offset is not an accident of the mechanism. It is the mechanism.
Lift all six at once and there is nothing holding the insect up. Lift them in some other pattern and at some point during the stride only two legs are down, which is a line rather than a triangle — and anything balanced on a line falls off it.
In step is not always right. Sometimes the whole design is the size of the gap between them.
Two motors can be related to each other in three useful ways. You have met two of them.
| Relationship | Speeds | Starting points | Seen in |
|---|---|---|---|
| Matched | Same | Same | Lesson 5 — the Stair Climber, going up square. |
| Different speeds | Different | Irrelevant | Lesson 11 — the Lawnmower, turning. |
| Out of phase | Same | Offset | Today. A gait. |
The third row is the odd one. The two motors run at identical speeds for the whole journey — they never disagree about anything — and yet they are permanently different, because one of them started later.
You cannot tell a motor “be half a turn behind that one”. So you do it by hand, once, before the walking starts:
[B v] run for (180) [degrees v] at (30) % speed :: motors [B v] start motor at (40) % speed :: motors [C v] start motor at (40) % speed :: motors
After that first block, B is half a cycle ahead of C. Both then run at 40 for as long as you like, and because they are going the same speed the gap never closes. Phase is an initial condition: you establish it once, and matched speeds preserve it.
Half a cycle is not always 180 degrees. If your leg linkage completes a full stride in one motor rotation, half a cycle is 180. If it takes two rotations, half a cycle is 360. Turn the motor by hand and watch the legs before you pick the number.
Because they exist to keep a pair matched — that is the whole point of them, and it is why Lesson 6 used them. A hexapod needs the two sides deliberately unmatched, so it uses two separate Motor blocks and takes responsibility for the relationship itself.
A driving base has two Large Motors, one per wheel. You could drive them with two separate motor blocks — but they would never start at quite the same instant, and the robot would curve away. EV3 has a separate family of Movement blocks that treat the pair as a single driving base.
| Block | What it does |
|---|---|
set movement motors to [B v] and [C v] :: movement | Tells the Movement blocks which two ports are the driving wheels. Put it at the top of the program, before any movement. |
move [forward v] for (2) [rotations v] :: movement | Drives both wheels together, so the robot travels in a straight line. |
move for (1) [rotations v] at (75) (25) % speed :: movement | Drives the two wheels at different speeds, which makes the robot curve. |
set movement speed to (50) % :: movement | Sets how fast the driving base travels from now on. |
set movement motors to [B] and [C] is the block that decides which two motors every Movement block after it will drive. It does not look at the robot. It drives the two ports you name, whether or not there is a motor in them — so those two letters have to be the two sockets the cables are actually in.
This is the single commonest reason a driving base does nothing, and it is invisible in the program: every block is spelled correctly and the robot still will not go.
the same program on both robots
The yellow outline marks the two ports the block is driving. A robot only goes straight when both of them have a motor in them.
Both robots run the identical program. The left one has its motors in B and C, so both named ports have a motor and the robot drives straight. The right one is plugged into A and B: the block drives B, finds nothing in C, and never mentions the motor in A at all — so one wheel turns, one wheel sits there, and the robot swings round the dead one instead of driving.
If neither named port has a motor in it — cables in A and D, say, with the block still set to B and C — the robot does not move at all. The program runs happily to the end and the Brick reports nothing wrong, because as far as it is concerned it did exactly what it was told.
So before you look for a bug in the program, look at the cables: read the port letters off the Brick, then make the block say those two. B and C are only the usual choice, not a rule — if your build has the driving motors in A and D, set the block to A and D and everything works.
Everything a driving base can do comes from those two speed numbers. Try each button below and watch the trail the robot leaves.
The path is worked out from the two wheel speeds in the block, not drawn by hand — so changing the preset changes the numbers and the shape together.
Notice there is no steering block anywhere in that program, and no steering part anywhere on the robot. The turn is made entirely by driving the two wheels different amounts.
when program starts :: events hat set movement motors to [B v] and [C v] :: movement move [forward v] for (2) [rotations v] :: movement move for (1) [rotations v] at (50) (-50) % speed :: movement
“Move forward 2 rotations” says nothing about the floor — it says how many times the wheels go round. How far the robot actually travels depends on how big the wheels are, and once round a standard EV3 driving wheel is about 17.5 cm.
Before doing any sums, get a feel for it. Drag the robot along and watch both scales at once — rotations on top, centimetres underneath, the same line. Land on the half marks: there is a number between 1 and 2, and it is 1.5.
Drag the robot, or use the arrow keys — it moves in half rotations. Rotations above the line, centimetres below.
1.5 — a half rotation past 1. Half a turn of the wheels is 8.75 cm, so halves matter.
35 ÷ 17.5 = 2. That is a number you can type straight into the block.
set movement motors to [B v] and [C v] :: movement set movement speed to (30) % :: movement move [forward v] for (2) [rotations v] :: movement
Steering at right 100 or left 100 drives the two wheels in opposite directions, so the base stops travelling and pivots where it stands. The angle it sweeps is a simple doubling of the rotations:
Half a rotation is the one worth remembering: a square corner, 90°.
| Rotations | The robot turns |
|---|---|
| 0.25 | 45° — half a corner |
| 0.5 | 90° — a square corner |
| 1 | 180° — turn round and face back |
| 2 | 360° — all the way round |
The one to memorise is 0.5 rotations = 90°. Everything else follows from doubling or halving it.
set movement speed to (20) % :: movement move [right: 100] for (0.5) [rotations v] :: movement
Turn slowly. The wheels on a driving base are big and the robot carries a lot of weight, so at full speed it keeps going after the motors stop and lands past the angle you asked for. Somewhere between 15% and 30% speed is where turns become repeatable. A turn that overshoots is almost always a turn taken too fast, not a wrong number.
These figures belong to your robot. The distance depends on the wheels and the angle depends on how far apart they are, so a wider base needs a different number for 90°. Test it, measure what actually happened, and adjust — the same discipline as the Gyro Sensor tolerance.
Every wheeled vehicle steers this way — a tank, a digger, an office chair with two driven castors. Cars use a steering rack instead, but a robot that turns by driving its wheels at different speeds needs no steering mechanism at all.
Set the offset once, then keep the speeds equal. Equal speeds are what protect the gap.
Everything an EV3 does begins with a motor turning. Before worrying about how far or how fast, there are only two things to say to a motor: start and stop. The blocks are the same whichever motor you use — only the port letter changes.
| Block | What it does |
|---|---|
[A v] start motor [clockwise v] :: motors | Starts the motor and immediately carries on to the next block. The motor keeps turning on its own. |
[A v] stop motor :: motors | Stops the motor. |
wait (2) seconds | Holds the program here, which is how you control how long a motor runs. |
Because start motor does not wait, a motor started on its own would run until the program ended. The pattern that gives a motor a length is three blocks:
when program starts :: events hat [A v] start motor [clockwise v] :: motors wait (2) seconds [A v] stop motor :: motors
Read it aloud: start it, leave it two seconds, stop it. Change the wait and you change how far the motor gets.
The highlight below follows the block the Brick is running, and the shaft turns only while the program is between start motor and stop motor. Notice that the count keeps climbing all the way through the wait — the wait does not pause the motor, it pauses the program.
0.00rotations so farnoshaft turning
The count does not pause when the program does. A wait holds up the blocks, and the motor carries on turning underneath it.
This is the whole idea behind start motor: it hands the motor its instruction and moves on, leaving the motor running behind it. Nothing stops the shaft until a block tells it to.
The direction dropdown says clockwise or counterclockwise — but clockwise seen from where? Always from the axle end: look straight at the shaft coming towards you, and clockwise is the way a clock’s hands go.
Here the Medium Motor faces you, so its output axle points straight out of the page. This is the view to picture when you are choosing a direction.
when program starts :: events hat [A v] start motor [clockwise v] :: motors wait (2) seconds [A v] stop motor :: motors
A Medium Motor normally lives in port A or D.
The Large Motor is shown from the side, which is the face its axle comes out of — so once again you are looking straight down the shaft.
when program starts :: events hat [B v] start motor [clockwise v] :: motors wait (2) seconds [B v] stop motor :: motors
A Large Motor normally lives in port B or C. Compare the two programs: they are the same three blocks, and only A has become B.
A fan, a conveyor belt or a spinning ride does not need to stop at an exact position — it just needs to run while something is happening. For those, timing the motor is simpler and perfectly good enough.
Say this back before moving on: “Same speed, different starting point.”
| Part | What it is doing here |
|---|---|
| EV3 Intelligent Brick | Sets the offset and then leaves the two motors alone. Its weight sits over the middle legs, which are the ones doing most of the supporting. |
| Large Motor ×2 — one per side | Ports B and C. Each drives three legs through a linkage, and the two are deliberately not synchronised. |
| The leg linkages (not electronic) | Each side’s three legs are already offset from each other within the side. Your job is only the offset between the sides. |
Sensors go in ports 1, 2, 3, 4. Motors go in ports A, B, C, D. They are not interchangeable, and nothing will tell you politely if you swap them.
| Part | Port | Why this one |
|---|---|---|
| Left legs (Large) | B | B is left. Today B is also the side that gets the head start. |
| Right legs (Large) | C | C is right, and starts from where it is. |
| Sensors | none | The gait is set up rather than sensed. Adding a sensor is what the challenges are for. |
Check your own build now:
Two routes, and either is fine. USB is the reliable one and the one to fall back on when a room’s Bluetooth is busy; Bluetooth leaves the robot free to move, which some models need.
Do these in order. Naming the Brick after you go looking for it in the list is how groups end up driving each other’s robots.
EV3 until somebody changes it.EV3.The two failures, every class, every time. The Brick has gone to sleep while you were building — press the centre button to wake it. Or you have paired with the group at the next table, which is why the name matters.
The long version, including Port View and how to read the port tiles, is in the Brick & Bluetooth guide.
Bluetooth. A walking model with six legs will find a trailing cable and stand on it.
Give the left side a half-cycle head start, then run both at the same speed and let the gait look after itself.
when program starts :: events hat clear display :: display write [HEXAPOD] at line (1) :: display write [Fasa...] at line (3) :: display [B v] run for (180) [degrees v] at (25) % speed :: motors write [Jalan ] at line (3) :: display [B v] start motor at (40) % speed :: motors [C v] start motor at (40) % speed :: motors wait (8) seconds [B v] stop motor :: motors [C v] stop motor :: motors write [Berhenti] at line (3) :: display
What success looks like: the hexapod walks steadily, and at every moment you can see three legs down and three swinging. Watch it from the side rather than above — the giveaway of a good gait is that the body stays at a constant height, because it is always resting on a tripod.
If it lurches or drags its belly, the offset is wrong for your linkage. Try 90 degrees, and 270. One of them will look markedly better, and that number is a property of your build.
Reset both sides to the same position by hand before every run. Watch the body height — it is the clearest single indicator of whether the gait is working.
Step 4 is the one worth sitting with. The two motors differ by five percent — almost nothing — and the gait survives for a few seconds and then collapses, because a small difference in speed accumulates into a large difference in position. That is the same error-adds-up problem the Lawnmower had at its corners, in a different costume.
A phase is only preserved by equal speeds. Any difference at all will eventually eat it.
Work through the challenges in order — each is harder than the last. The mission comes after all three, and it is meant to make you plan before you build.
Find the offset that walks best. Try 90, 180 and 270 degrees of head start, and report which gave the steadiest walk on your build. Watch the body height rather than the legs.
Show what no offset does. Run it with both sides starting together and describe exactly what goes wrong — whether it bounces, drags or falls, and why three legs down matters.
Break the phase with speed. Set one motor 5% faster than the other and time how long the gait survives before it falls apart. Then explain why a small speed difference becomes a large position difference.
Make the hexapod walk a set distance and still be walking properly at the end. Mark a start and a finish about a metre apart. Your hexapod has to cross it with a gait that looks as good at the finish line as it did at the start. Plan it first. Decide the offset from your own testing, decide the speed, and predict how long the crossing will take. Then decide how you will judge "still walking properly" — before the run, and in a way somebody else could check. Run it at least three times and record whether the gait held each time. Two questions when you present it. Did the gait decay over the distance, and if so what would you have to add to hold it together? And your offset is set once at the start and never checked again — describe what the robot would need in order to notice its own gait had drifted and fix it.
Build the model before you read any further. Everything after this is about making it do something, and none of it will make much sense with nothing on the table in front of you.
Use the viewer's own controls to zoom and turn pages. Fullscreen makes it big enough to build from.
Check the finished build against the picture before you switch anything on. A motor mounted the wrong way round is far easier to spot now than it is to debug later, when it looks like a program fault.
