Coding Project 14 — Seeing Light and Dark
KIPR · Botball Explorer
Activity Sections

Introductory · EV3 Coding Project 14

Seeing Light and Dark

A sensor that answers with a number, not a yes.

Project
Coding Project 14
Strand
Coding
Phase
Make It Smart
Time
One class period
What You Are Doing
Reading a that measures brightness, choosing your own decision point, and using the black line to place things exactly inside the Loading Zone.
Mission Anchor
Mission 14 bonus · Mission 18 bonus + advanced — 35 points
What You Need
Before You Start
Projects 10, 11, and 13 — checking, measuring, and choosing.
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 — How Dark Is It?

Your touch sensor answers one question: am I pressed? Yes or no. Nothing else.

This one is different. Plug the color sensor into sensor port 3 and write that on your card. On the brick, open Port View on port 3, and press the center button until the mode reads reflected light (the brick calls it COL-REFLECT). Then watch the number while you hold the sensor over things.

⚠ Hold It Close, Not Touching

Pointed straight down, roughly half an inch off the surface. Pressed against the surface or held way up both give you useless numbers.

Held over…Reading (%)
The white part of the game field
A black line on the field
Your desk
Something dark you find in the room
Something light you find in the room
Which gives the bigger number — dark surfaces or light ones?

The sensor shines a tiny light down and measures how much bounces back. Use that to explain why the numbers came out the way they did.

There Is No "Black" Reading

You did not get a yes or a no. You got a number somewhere between 0 and 100, and it wobbles a little every time you look.

So you have to decide where black starts. The sensor will not do it for you.

Learn It — Pick Your Own Dividing Line

Reflected light is a range reading, not a switch — the other pile from your Project 10 sort, finally in play.

Code / partWhat it means
~95White — nearly all the light bounced back.
~10Black — most of the light was swallowed.

Your numbers will not match anyone else’s. Different mounting height, different room lighting, different sensor.

Your threshold

A is the number you pick as the dividing line. Above it, call it white. Below it, call it black.

The usual starting point is halfway between your two readings:

Code / partWhat it means
threshold = (white + black) ÷ 2For example: (95 + 10) ÷ 2 ≈ 52. A starting guess, not a final answer. You will adjust it.

Make it a called threshold, set at the top with the rest — you have known better than bare numbers since Project 9.

Your third kind of question

The checking has not changed at all. Only what it watches.

Read the new one out loud: “keep checking the brightness — the moment it drops below my threshold, the sensor is seeing black. Move on.”

When It Does Not Work, Move the Threshold

Stops too early, on plain white? Your threshold is too high — the wobble dips under it. Move it down, toward your black value.

Drives straight over the line? Your threshold is too low. Move it up, toward your white value.

Also check the obvious: is the sensor pointed straight down, about half an inch off the mat?

Starting the match

Your match start has been a tap on the touch sensor since Project 10. The same brightness trick gives you a second option: point a color sensor up, and wait until its reading jumps — the moment a light comes on over it, or a flashlight hits it.

Which start your tournament uses is a rules question — check with your coach. The blocks are ready either way.

Do It — Find the Line, Then Use It

Step 1 — Mount it and set your threshold

Fix the color sensor to the front underside of your robot, pointing straight down, about half an inch clear of the mat. Then take fresh readings from the mounted position — they will not match what you got holding it in your hand.

MeasurementValue
Port I used
White reading, mounted
Black reading, mounted
My threshold — (white + black) ÷ 2

Step 2 — Find the Line

New project called Find the Line. Drive forward until the sensor sees black, then stop: start moving, wait until reflected light < threshold, stop moving, settle. Threshold and steering as variables at the top.

TryThresholdWhat happened
1
2
3

Step 3 — Three lines, three distances

The real test of a threshold is whether it works when you did not tune it for that exact spot. Set your robot at three different distances from a line and run the same program each time, changing nothing.

Starting distanceDid it stop on the line?

This Is Something a Counter Cannot Do

A distance only works from a known starting point. This program finds the line from anywhere — it does not care where it began.

Step 4 — Drive to black, back up to black

Now do it twice in a row. Drive forward to a line, stop, then reverse until you find a line again.

⚠ Think Before You Build This One

When the robot stops, it is sitting on black. Start the reverse check immediately and it succeeds on the very line you are still on. You have to get back onto white first — wait until the reading climbs above the threshold — and only then start looking for the next fall below it.

Write the order of checks you ended up with, in plain words.

Step 5 — Start on a signal

Add a match start to the top of the program — your force-sensor tap, or the point-a-sensor-up light start from Learn It if your tournament uses lights. Test it: the robot must sit dead still until the signal, then go.

Step 6 — Mission 14 Bonus — a cone IN THE ZONE7 pts

Mission 14

Traffic Control

Watch Mission 14 video

Base Mission

3 points Live judged

Both Traffic Cones satisfy the definition.

Bonus Mission

7 points Final judged

A Traffic Cone is the Loading Zone. The Base Mission must be satisfied to score the Bonus Mission.

Scores

  • Both Traffic Cones are the black line.
  • A Traffic Cone is the Loading Zone while the other remains elsewhere on the field.
  • The same Traffic Cone used for Base Mission is placed the Loading Zone.

Does Not Score

  • Either Traffic Cone is touching black line.
  • Only one Traffic Cone is the black line.
  • A Traffic Cone is the Loading Zone but the second cone is still touching black line.
  • The Base Mission has not been satisfied.

⚠ The Base Still Has to Hold

You cannot score this bonus unless both cones are OFF the black line — including the one you left behind. If your second cone drifted back onto the line, the bonus is worth nothing.

Use your line-finding program to drive to the Loading Zone , then place the cone.

Step 7 — Mission 18 — Botguy and both cones28 pts

Watch Mission 18 video

Base Mission

11 points Final judged

Botguy is the Loading Zone.

Bonus Mission

13 points Final judged

Botguy is the Loading Zone AND at least one Traffic Cone is the Loading Zone.

Advanced Bonus

15 points Final judged

Botguy is the Loading Zone AND both Traffic Cones are the Loading Zone.

Scores

  • Botguy is the Loading Zone.
  • Botguy and one Traffic Cone are the Loading Zone.
  • Botguy and both Traffic Cones are the Loading Zone.

Does Not Score

  • Botguy is outside the Loading Zone.
  • Botguy is touching only the exterior boundary of the Loading Zone.
  • A Traffic Cone is the Loading Zone but Botguy is not.
  • Botguy and only one Traffic Cone are the Loading Zone for the Advanced Bonus.

⚠ IN and FULLY WITHIN Are Not the Same Thing

Mission 14’s bonus only needs a cone IN the zone — any part of it poking into the interior counts.

Mission 18 needs the cones FULLY WITHIN — every single part inside, nothing touching or crossing the .

A cone half over the line scores Mission 14 and nothing from Mission 18. This is exactly why you need the sensor: it tells you where the boundary actually is.

Scores

  • Botguy and one cone FULLY WITHIN the zone.
  • Botguy and both cones FULLY WITHIN the zone.
  • Botguy and the cones do not have to touch each other.

Does Not Score

  • A cone is but Botguy is not.
  • Botguy touching only the outside boundary of the zone.
  • Botguy and only one cone, for the Advanced Bonus.

One Delivery, Three Scores

Put Botguy and both cones fully inside the Loading Zone and you collect Mission 14’s bonus, Mission 18’s bonus, and Mission 18’s advanced — 35 points from one trip pattern.

Every part of this is final position, so nothing may drift out before the match ends.

Which order will you deliver them in, and why that order?

Step 8 — Run it five times

RunM14 bonusM18 bonusM18 advancedPoints
1
2
3
4
5
If a placement failed, was it the driving or the letting go?

Score It — Checkpoint

My score

Mission partScored?Points
Mission 14 — Bonus (a cone IN the Loading Zone)7
Mission 18 — Bonus (Botguy + one cone FULLY WITHIN)13
Mission 18 — Advanced (Botguy + both cones FULLY WITHIN)15
My total35

My sensor card

SettingValue
Port my color sensor is in
White reading, mounted
Black reading, mounted
My working threshold

IN or FULLY WITHIN?

Say whether each one satisfies IN, FULLY WITHIN, both, or neither.

The cone is…Which definition?
Sitting well inside the zone, nothing near the edge
Mostly inside, with its base edge resting on the boundary line
Just its tip poking over the boundary into the zone
Right beside the zone, touching the outside of the line

Fix the threshold

A teammate’s robot misbehaves. Say which way their threshold should move — remember: with this sensor, black is low.

The robot…Move the threshold…
Stops on plain white, before any line
Drives straight over the line and keeps going
Works on one side of the field but not the other

Can you do it again?

Think about it

Your threshold works perfectly in your classroom. The tournament room has huge windows and much brighter light. What might happen, and what would you do about it on the day?

Your robot now has three ways to know where it is: bumping something, counting wheel degrees, and reading brightness. Which one would you trust most, and does the answer change depending on the job?

Right now the sensor only tells your robot to stop. What if it kept reading while driving, and steered based on what it saw?

Next

That last question is the whole of the next project. In Project 15 — Following the Line, the sensor stops being a stop sign and becomes a steering wheel.

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