Coding Project 10 — Feeling for Things
KIPR · Botball Explorer
Activity Sections

Introductory · SPIKE Coding Project 10

Feeling for Things

Your robot gets its first sense — and its first way of saying keep going until .

Project
Coding Project 10
Strand
Coding
Phase
Make It Reliable
Time
One class period
What You Are Doing
Mounting a touch , learning the loop that keeps checking it, and using contact to find a position your robot can trust.
Mission Anchor
Mission 13 — Straighten Up (advanced bonus) — 13 points
What You Need
Before You Start
Project 9 — you need to be comfortable writing and using s.
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 — Walking in the Dark

Imagine the power is out and you are trying to cross a room you know well. Your eyes are useless. So you put a hand out in front of you and start walking.

Actually do it. Stand a few steps from a wall, close your eyes, put one hand out, and walk slowly toward it until you touch it.

How many times did you check whether your hand had reached the wall?

You did not check once and hope. What were you doing the whole time you were walking?

That Is a Loop

Check. Step. Check. Step. Check — touched something — stop and do something different.

Repeating a check while you wait for something to become true is called looping, and it is the whole idea of this project.

Sort your sensors

Get your kit’s three sensors out on the table — force, color, distance. Without looking anything up, sort them into two piles. You decide the rule.

What went in it
Pile 1
Pile 2
What rule did you use?

One Split Matters More Than the Others

Some sensor questions work like a light switch — yes or no, and nothing in between. Is the button pressed? Others answer with a whole range — how bright? how far?

If that is how you sorted them, you found the split programmers care about. Today is a light-switch day: the force sensor, asked one yes-or-no question.

Learn It — Keep Checking Until

A turns something physical — a press, a color, a distance — into something your program can read.

True or false

The force sensor’s yes-or-no question comes as a six-sided block — a hexagon. Hexagons do not do anything on their own. Each one is a question with exactly two possible answers: true or false.

Not pressed → the hexagon answers false. Pressed → it answers true. Nothing in between — a light switch, exactly like your sorting rule.

Why the wait block cannot help you here

Every time you needed the robot to wait, you used wait 2 seconds. That will not work now. A sleeping program cannot notice anything. If you tell it to wait two seconds and the sensor is pressed after half a second, the robot never knows.

You need it to keep checking — over and over, as fast as it can. Hexagons snap into two Control blocks built for exactly that:

Wait until asks its question as fast as it can, thousands of times a second, and does not let the next block run until the answer is true. It is your hand-out-in-the-dark, as a block.

Repeat until is the same idea with a mouth: everything held inside its jaws runs over and over, as long as the answer is still false. The moment the answer turns true, the robot falls out of the jaws and moves on to whatever comes after.

Inside the Jaws, and After Them

What goes inside is the thing to keep doing. What goes after is what happens when the answer finally changes. Deciding which is which is the whole skill.

Drive until bump

Put it together. Read it out loud: “start driving — keep checking until the sensor is pressed — then stop.”

⚠ The Stop Goes After, Not Inside

The wait until is the checking. The stop moving is what happens when the checking succeeds. Put the stop before the wait and the robot never moves; forget the start moving and the robot waits forever at a standstill, checking a sensor nothing will ever press.

Comparing numbers

Hexagons are not only about sensors. The green Operators shelf has three comparison hexagons, and they turn any pair of numbers into a true-or-false question:

HexagonAsksExample
<is the left smaller?5 < 4 is false
=are they equal?5 = 5 is true
>is the left bigger?5 > 4 is true

Today your question is is pressed? and you will not need these. But hold on to them — in Project 11 the loop stops watching a switch and starts watching a number, and these hexagons are how you ask about numbers.

One more: the green not hexagon flips an answer. not (F is pressed?) is true exactly when the sensor is not pressed. You will want it the moment you need “keep going while nothing is touching.”

Do It — Drive Until Bump

Step 1 — Mount the sensor and read it live

Mount your force sensor on the front of the robot so it hits things before anything else does. Plug it into port F.

In the app, open the device view. Press the sensor with your finger and watch what it reports.

QuestionMy answer
Which port is my force sensor in?
What does it show when nothing touches it?
What does it show when I press it?

Step 2 — Drive Until Bump — in your hands first

⚠ Hold the Robot in the Air for the First Run

Do not put this on a table or the field yet. Hold the robot up so the wheels spin freely, run the program, then press the sensor with your finger and watch the wheels stop.

A loop that never sees its sensor never stops. Find that out in your hands, not off the edge of a table.

New project called Drive Until Bump. Plan it as first, then build the start-moving / wait-until / stop-moving stack from Learn It.

Step 3 — Flip the condition and predict

Wrap the hexagon in a green not: wait until not (F is pressed?). Before you run it, write down what you think will happen.

My prediction:

Now run it. Then run it again while holding the sensor pressed the whole time.

What actually happened, both times? Explain why, using the words “true” and “false”.

Take the not back out.

Step 4 — Bump and Go Home

Here is what makes a force sensor genuinely useful: a wall is a place your robot can always find.

New project. Mount or turn the sensor so it faces backward — then drive backward until the sensor presses against the starting box wall, and drive forward a set distance into the box and stop.

Code / partWhat it means
1. Start moving backwardA negative speed, or steering with a backward start — your choice.
2. Wait until pressedThe wall ends the trip, wherever the robot wandered from.
3. Stop and settle
4. Move forward a set distanceInto the box.

Why This Matters More Than It Looks

No matter where the robot wandered off to, it can come back and touch a wall — and now it knows exactly where it is. Every measurement after that starts from a spot it can trust.

Step 5 — Add a stop and settle

A robot that has been driving is still rocking when the checking ends. Momentum does not care about your program. Put a short wait 0.5 seconds between the stop and whatever comes next, and compare runs with and without it.

What difference did the pause make?

Step 6 — Wait for a press before starting

One more use for the same idea. Put a wait until (F is pressed?) block at the very top of a mission program, before anything moves.

Now your robot waits for a tap on its sensor instead of driving off the second you press Run — which is exactly how you want to start a match.

That wait-until block has no jaws and nothing inside it. Is it still doing something the whole time? What?

Step 7 — Mission 13 Advanced — all three cubes13 pts

Watch Mission 13 video

Base Mission

1 point Live judged

All three Unstraight Cubes satisfy the definition (cubes are the black line).

Bonus Mission

7 points Live judged

Two Unstraight Cubes form a scoring stack — one Unstraight Cube is another.

Advanced Bonus

13 points Final judged

All three Unstraight Cubes form a scoring stack. All cubes must originate from the Unstraight Cube area.

Scores

  • All three Unstraight Cubes are the black line.
  • One Unstraight Cube is another Unstraight Cube.
  • All three Unstraight Cubes participate in valid relationships (traditional stack or pyramid).

Does Not Score

  • One or more Unstraight Cubes are touching the black line.
  • Two Unstraight Cubes touching side-by-side without .
  • An Unstraight Cube stacked with a cube from another mission area.
  • Only two Unstraight Cubes participate in the Advanced Bonus stack.

A Pyramid Counts --- and It Is Easier

Read the scoring examples again. A pyramid scores exactly the same as a three-high tower. Two cubes on the bottom, one on top.

This is a final-position mission, so whatever you build has to still be standing when the match ends. A pyramid is far harder to knock over than a tower. Take the easy 13 points.

Use the force sensor to make your approach repeatable. If your robot can find a wall or a cube by contact instead of by timing, every placement after that starts from a known spot.

Where in your run does the force sensor help most — finding the cubes, or finding your way back?

Step 8 — Run it five times

RunAll three stacked?Still standing at the end?Points
1
2
3
4
5

Did the stack fall over on any run? What knocked it — the robot leaving, or the stack itself?

Score It — Checkpoint

My score

Mission partScored?Points
Mission 13 — Advanced Bonus (all three cubes stacked)13
My total13

With Project 6 and Project 8, Mission 13 is now worth 21 points across all three parts — the most any single mission has given you.

Finish the check

Say which blocks you would use for each.

I want the robot to…My blocks
Drive until the sensor is pressed
Drive while the sensor is pressed, stop when released
Do nothing until someone taps the sensor

Spot the bug

Each of these is wrong. Say what happens when you run it.

The stackWhat goes wrong
start moving · wait 2 seconds · stop moving — used to “wait for the bump”
wait until pressed · start moving · stop moving
stop moving inside the jaws of a repeat-until that is supposed to be driving
wait until pressed, with no start moving anywhere

Can you do it again?

Think about it

Since Project 3, every distance your robot has driven was really a length of time. What does a force sensor give you that a stopwatch never could?

A force sensor only tells you something when you are already touching it. Name one thing on the field you would want to stop at, where bumping into it first would be a bad idea.

Your loop asks a question over and over. So far the question has always been about a sensor. What else could a robot count or measure that a loop could watch?

Next

A wall tells you where you are, but only if there is a wall. Most of the field has nothing to bump into.

In Project 11 — Counting and Turning by Feel, you point the same checking at a number instead of a switch — the degrees your wheels have rolled, and the angle the whole robot has turned. The hub has been measuring both all along.

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