Coding Project 15 — Following the Line
KIPR · Botball Explorer
Activity Sections

Introductory · EV3 Coding Project 15

Following the Line

The sensor stops being a stop sign and becomes a steering wheel.

Project
Coding Project 15
Strand
Coding
Phase
Make It Smart
Time
One class period
What You Are Doing
Steering from a reading instead of driving blind, then using the lines to reach four of the hardest scoring targets on the field.
Mission Anchor
Mission 6 · Mission 7 base · Mission 16 base · Mission 17 base — 51 points
What You Need
Before You Start
Project 14 — you need a working and a robot that can find a line.
Before you start: type your PIN in the box at the top of the page. Your teacher gave you this number. When you finish, press Download to save a local copy of your answers. This does not turn in your work automatically; give the downloaded file to your teacher.

Try It — Where Is the Line, Exactly?

Put your robot on the field with the sensor over a black line. Open the live reading, then push the robot sideways by hand, slowly, across the line and off the other side. Watch the number the whole way.

Sensor sitting…Reading
Well off the line, on white
Right at the edge, half on and half off
Dead centre of the line
Right at the other edge
Well off the other side, on white

Now the question that matters

Look at your first reading and your last reading — both on white, one either side of the line. Can the sensor tell them apart?

Your robot drifts off the line. Just from the number, can it work out which way it drifted?

⚠ One Sensor Cannot Stay on the Middle

Sitting on the centre of the line, everything looks the same in both directions. Drift left, the reading climbs toward white. Drift right, the reading climbs toward white. The robot has no idea which happened, so it cannot know how to correct.

Following the middle of a line with one sensor is impossible. So you do not.

Learn It — Follow the Edge, Not the Line

Put the sensor on one edge of the line and everything becomes answerable. Now dark and light mean two different directions.

Code / partWhat it means
On the edgeExactly where you want to be. Reading sits near your .
Drifted onto blackReading is low. Steer away from the line.
Drifted onto whiteReading is high. Steer back toward the line.

The Robot Never Drives Straight

It zigzags. Too dark, arc one way. Too light, arc back. Over and over, several times a second.

From a distance it looks like the robot is following the line. Up close it is constantly overcorrecting — and that is exactly what makes it work.

Two choices, checked forever

This is a repeating loop with an if-then-else inside it. You have had both since Projects 10 and 13 — this is the first time they work together.

Code / partWhat it means
repeat until (…)Keeps the whole thing going. Without it the robot checks once and gives up.
if / elsePicks one of two steering arcs, every single trip round.
no stop insideNever stop the motors inside the jaws. The robot should steer continuously, not stutter.

⚠ Keep the Steering Under 50

It is tempting to make the corrections sharper by cranking the steering toward 100. Do not. Past 50, the inside wheel starts running backward — and in a loop that flips direction several times a second, that slams the drivetrain back and forth violently and makes the robot lurch instead of flow.

Stay in arc territory: two mirrored values under 50. A big number gives a sharp correction; a small one gives a gentle glide. That is the same steering rule you found in Project 5 — it has been true this whole time.

Tuning it

ProblemTry this
Wanders off the line and never comes backBigger steering number — correct harder
Zigzags so wildly it barely moves forwardSmaller steering number — correct more gently
Loses the line on sharp corners onlySlow the speed down, or sharpen just the inside arc
Follows for a while then drives offCheck your threshold — right for one part of the field, wrong for another

Following until something else happens

Line following on its own goes forever. To be useful it has to stop for a reason — a distance travelled, a bump, or a second line crossing the first.

Swap the hexagon on the outer jaws. Reset a wheel’s count first, then repeat until (A degrees counted > your degrees-per-inch × the distance) — the same if/else inside.

Now the line keeps you straight and the counter tells you when you have arrived. Two sensors doing two different jobs in one loop.

Do It — Steer and Deliver

Step 1 — Build the follower

New project called Line Follow. Build the two-choice loop from Learn It. Put the sensor on the left edge of a line and let it run until you press the touch sensor.

TrySteering ±SpeedWhat it did
1
2
3
4

Step 2 — Switch edges

Move the robot to the other edge of the same line and run the identical program.

What happened, and why?

What single change makes it follow the right edge instead?

Step 3 — Follow a curve

Straight lines are easy. Find a line on the field that bends and follow that.

Did you have to change anything from your straight-line settings?

Step 4 — Follow, then stop for a reason

Wrap the follower in the counted version from Learn It: reset the wheel count, follow the line until the count says you have gone your chosen distance, then stop and settle.

Two readings are steering one loop. Say in one sentence what each one is responsible for.

Step 5 — Mission 16 — Freight Shelving9 pts

Watch Mission 16 video

Base Mission

9 points Final judged

At least one cube originating from the Spilled Cube area is the Large Green Cube.

Bonus Mission

11 points Final judged

Two or more cubes originating from the Spilled Cube area are the Large Green Cube.

Scores

  • One spilled cube is the Large Green Cube.
  • One spilled cube is the Large Green Cube while supported by a robot.
  • One spilled cube another spilled cube that is the Large Green Cube.
  • Multiple spilled cubes the Large Green Cube.

Does Not Score

  • A spilled cube touching only the side of the Large Green Cube.
  • A spilled cube not originating from the Spilled Cube area.
  • Only one spilled cube the Large Green Cube for the Bonus Mission.

⚠ The Large Green Cube, Not a Small One

The target is the large palletized Green Cube field element — not the small green cubes you have been stacking since Project 8. Make sure your team is aiming at the right thing.

Robot support is permitted, but this is final position scored — so the cube has to still be up there at the end, which means letting go cleanly.

Step 6 — Mission 17 — Freight Racking9 pts

Mission 17

Freight Racking

Watch Mission 17 video

Base Mission

9 points Final judged

At least one cube originating from the Unstraight Cube area is the Large Brown Cube.

Bonus Mission

11 points Final judged

Two or more cubes originating from the Unstraight Cube area are the Large Brown Cube.

Scores

  • One Unstraight Cube is the Large Brown Cube.
  • One Unstraight Cube another that is the Large Brown Cube.
  • Multiple Unstraight Cubes the Large Brown Cube.

Does Not Score

  • An Unstraight Cube touching only the side of the Large Brown Cube.
  • A cube not originating from the Unstraight Cube area.
  • Only one Unstraight Cube the Large Brown Cube for the Bonus Mission.

Same Job, Different Address

This is Mission 16 with two words changed. If you built Mission 16 as a My Block with inputs, this one costs you almost nothing — which is the reward for the work you did in Project 12.

⚠ Watch Your Cube Budget

The Unstraight Cubes are the same three you stacked for Mission 13 back in Project 10. A cube can only be in one place at the end of the match. Decide now which missions you are actually going for.

Step 7 — Mission 7 — Hazard Containment11 pts

Watch Mission 7 video

Base Mission

11 points Final judged

One Blue Pom and one Orange Pom are the same PVC enclosure.

Bonus Mission

9 points Final judged

A second PVC enclosure contains at least one Blue Pom and at least one Orange Pom, each the enclosure. The Base and Bonus must use different enclosures.

Scores

  • One Blue Pom and one Orange Pom are the same PVC enclosure.
  • Multiple Blue Poms and one Orange Pom are the same PVC enclosure.
  • Two different enclosures each containing at least one Blue and one Orange Pom.

Does Not Score

  • A Blue Pom in one enclosure and an Orange Pom in a different enclosure.
  • Only one pom type in any enclosure.
  • The same enclosure used to satisfy both Base and Bonus Missions.

Two colours, one enclosure. Poms roll, so the second delivery is the one that knocks the first one out — go slowly and back straight away.

Step 8 — Mission 6 — Pallet Builder22 pts

Watch Mission 6 video

Base Mission

15 points Live judged

Place all four Green and Yellow Cubes onto a single pallet. A cube is on the pallet if touching the upper surface or another cube that is on the pallet.

Bonus Mission

7 points Final judged

The pallet is a starting box and is not touching any black line.

Scores

  • All four cubes touching the pallet.
  • A four-cube vertical stack on the pallet.
  • Any arrangement where all four cubes are part of a single palletized load.
  • The pallet a starting box, not touching the black line.

Does Not Score

  • Three cubes on the pallet and one cube elsewhere.
  • The pallet is touching the black line.
  • The pallet is not a starting box.

The Arrangement Does Not Matter

Four cubes flat on the pallet, a four-high tower, or anything in between — all of it scores, as long as every cube is part of one palletized load. Pick whatever your claw finds easiest.

Better still: the cubes are not required to stay on the pallet after the base is scored. It is live judged, so once the judge has seen four cubes on the pallet, you can go on and move the pallet without worrying about a cube rolling off.

⚠ Not TOUCHING Any Black Line

The bonus is stricter than it looks. The pallet must be FULLY WITHIN the starting box and clear of every black line. Push it in too far or not far enough and you get nothing.

These are the same four green and yellow cubes you used for Mission 3 in Projects 8 and 13. What is your plan — Mission 3’s stacks or Mission 6’s pallet?

Step 9 — Run it five times

RunM16M17M7M6 baseM6 bonusPoints
1
2
3
4
5

Score It — Checkpoint

My score

Mission partScored?Points
Mission 16 — Base (spilled cube on the Large Green Cube)9
Mission 17 — Base (unstraight cube on the Large Brown Cube)9
Mission 7 — Base (blue + orange in one enclosure)11
Mission 6 — Base (four cubes on one pallet)15
Mission 6 — Bonus (pallet in a starting box)7
My total51

My line-following settings

SettingValue
Steering toward the line / away from the line
Speed while following
Which edge my robot follows
Threshold I follow with

Can you do it again?

Think about it

Your line follower checks and steers several times a second and never drives perfectly straight. Would a person following a line with their eyes shut, feeling for the edge with a foot, do anything different?

A second sensor, mounted a few inches away from the first, would let the robot see both edges at once. What could it do then that it cannot do now?

Missions 16 and 17 want two or more cubes for the bonus, and Mission 7 wants a second enclosure. Look at how you wrote these runs. What would it take to do each one a second time?

Next

You have built every skill this game needs. What you have not done is tidy up — your best blocks are scattered across a dozen projects, and half your missions have a bonus that just means “now do that again.”

In Project 16 — Building Your Toolbox, your blocks move into one master project that every new mission starts from.

Download saves a local copy of your answers. It does not turn in your work automatically; give the downloaded file to your teacher.

KIPR · Botball Explorer — Introductory Projects · © KISS Institute for Practical Robotics 1997–2026