Base Mission
7 points Live judgedA robot is Botguy.
Discovery · Coding Project 11
Same loop as last time — but now it watches a number instead of a switch.
Student PIN:
Back in Project 3 you dragged the slider on the Motors screen and noticed a number changing next to each . You were told to remember it. Here it is.
Open the Motors screen on the Wombat. Do not run anything — just turn a wheel with your hand and watch.
| Question | What I saw |
|---|---|
| What happens to the number when I roll the wheel forward? | |
| What happens when I roll it backward? | |
| What happens if I roll it backward past where I started? |
Every Motor Has Been Counting This Whole Time
Since Project 3, your motors have been keeping track of exactly how far they turned. You just didn’t know how to ask them.
are the motor’s own unit. To use them you need to know how many make an inch on your robot.
| Try | Ticks for 24 inches | Ticks per inch (divide by 24) |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| Average |
⚠ Measure Long, Not Short
Use 24 inches, not 3. A small error in a short push turns into a big error per inch. Anything under about a foot is not worth measuring.
Your three numbers are not identical. Why not — and which one should you use?
A tick is one small step of the motor shaft. There are about 1820 ticks in one full revolution of the shaft.
Wheel Size Does Not Change the Ticks
1820 ticks is one turn of the motor shaft, no matter what wheel you bolt to it. But a bigger wheel travels further in that one turn — which is exactly why your ticks-per-inch is yours and not somebody else’s.
| Code / part | What it means |
|---|---|
clear_motor_position_counter(0); | Sets the counter for port 0 back to zero. Short name: cmpc(0). |
get_motor_position_counter(0); | Gives you the number of ticks that motor has turned. Short name: gmpc(0). |
Both names do the same thing. The short ones are quicker to type and you will see both in other people’s code.
Look at these two side by side. Only the changed.
Project 10 — a switch
while (digital(bump) == 0)
{
motor(left, 50);
motor(right, 50);
}
motor(0, 0);
motor(3, 0);
msleep(30);Project 11 — a number
while (gmpc(left) < 4000)
{
motor(left, 50);
motor(right, 50);
}
motor(0, 0);
motor(3, 0);
msleep(30);Read the new one out loud: “While the left motor has turned fewer than 4000 ticks, keep driving. The moment it reaches 4000, stop.”
Why This Is Better Than a Wall
A touch only helps where there is something to touch. A tick counter works anywhere on the field — open floor, mid-turn, anywhere. Your robot finally has a way to know how far it has gone without hitting something.
Always clear before you count:
// Start counting from zero
cmpc(left);
while (gmpc(left) < 4000)
{
motor(left, 50);
motor(right, 50);
}
motor(0, 0);
motor(3, 0);
msleep(30);
// Let it settle
msleep(500);Run that program with a target of 4000 and then check the Motors screen. You will not see 4000. You will see something like 4310.
Nothing is broken. Your robot has — it is moving, and when the loop shuts the motors off it keeps coasting.
The Fix Is Subtraction
Ask for 4000. Get 4310. The is 4310 − 4000 = 310.
So ask for 4000 − 310 = 3690 instead, and you will land on 4000.
Every robot has its own overshoot. Faster power means more of it.
Driving in reverse decreases the counter, and it will go negative. That gives you two ways to come home.
Do not clear — count back to 0
cmpc(left);
// Drive Out
while (gmpc(left) < 4000)
{
motor(0, 0);
motor(3, 0);
msleep(500);
}
// Drive Home
while (gmpc(left) > 0)
{
motor(0, 0);
motor(3, 0);
msleep(30);
}Clear again — count to −4000
cmpc(left);
// Drive Out
while (gmpc(left) < 4000)
{
motor(0, 0);
motor(3, 0);
msleep(500);
}
cmpc(left);
// Drive Home
while (gmpc(left) > -4000)
{
motor(0, 0);
motor(3, 0);
msleep(30);
}Both work. The first one always returns to where it started, no matter how far out it went. The second one always travels the same distance back. Those are not the same thing, and one day the difference will matter.
⚠ Get the Direction Right or the Loop Never Ends
Driving backward with while (gmpc(left) < 4000) is a loop that can never finish — the number is going down, away from 4000, forever.
Going forward, count up with <. Going backward, count down with >. Check this before every run.
Create a new project called Ticks. Clear, drive to 4000 ticks, stop. Then check the Motors screen for what you actually got.
| Power | Asked for | Actually got | Overshoot |
|---|---|---|---|
| 30 | 4000 | ||
| 50 | 4000 | ||
| 100 | 4000 |
What is the relationship between power and overshoot?
Subtract your overshoot from your target and run again. Keep adjusting until the robot lands on 4000.
| Try | Target in my code | Where it actually stopped |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 |
Use your ticks-per-inch from Try It. Work out the ticks for each distance, then test it with a ruler.
| I want | Ticks (inches × TPI) | How far it really went |
|---|---|---|
| 6 inches | ||
| 12 inches | ||
| 24 inches |
Which distance was least accurate? Why do you think that is?
Drive out 4000 ticks, stop and settle, then return to exactly where you started. Use whichever of the two methods from Learn It you prefer.
Create a new project called Right Turn. — one wheel forward, one back, same speed — but this time stop it by counting ticks instead of by time.
cmpc(left);
while (gmpc(left) < turnTicks)
{
motor(left, 50);
motor(right, -50);
}
motor(0, 0);
motor(3, 0);
msleep(30);| Try | Ticks | Too far, not far enough, or right? |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 |
In Project 5 you drove a square with four timed turns and it did not close. Do it again — same square, but every distance and every turn counted in ticks.
| Question | Project 5 (time) | Now (ticks) |
|---|---|---|
| How close to the starting spot? | ||
| Facing the same way? |
This Is the Whole Point of the Project
Same robot. Same square. The only thing that changed is what the robot was measuring — and suddenly it can come back to where it started.
Your timed square drifted a little more with every corner. Why does a tick-counted square not do that?
Mission 9 A robot is Botguy. Botguy is outside the enclosure AND is touching the warehouse floor.Recover Botguy
Watch Mission 9 video
Base Mission
7 points
Live judgedBonus Mission
9 points
Live judgedScores
Does Not Score
Mission 18 Botguy is the Loading Zone. Botguy is the Loading Zone AND at least one Traffic Cone is the Loading Zone. Botguy is the Loading Zone AND both Traffic Cones are the Loading Zone.Safety First, All Hands on Deck
Watch Mission 18 video
Base Mission
11 points
Final judgedBonus Mission
13 points
Final judgedAdvanced Bonus
15 points
Final judgedScores
Does Not Score
One Trip, Two Missions, Twenty Points
You just lifted Botguy out of the enclosure for Mission 9. Do not put him down — carry him to the Loading Zone and Mission 18’s base scores too.
This is exactly the kind of thing to look for when you plan a full match: one action, more than one mission.
Mission 18 is final position, so Botguy has to still be when the match ends. Set him down properly and back straight away.
Mission 8 The pallet with the Large Red Cube is the Loading Dock. One or more Small Red Cubes are the Large Red Cube while the pallet is on the Loading Dock.Deliver the Red Cube
Watch Mission 8 video
Base Mission
11 points
Final judgedBonus Mission
9 points
Final judgedScores
Does Not Score
⚠ The Pallet and the Cube Travel Together
Read the failures carefully. The Large Red Cube on the Loading Dock without the pallet does not score. Neither does a pallet on the dock with the cube fallen off.
They both have to end up there, cube on pallet, pallet on dock.
Look at What You Already Did to These Cubes
In Project 6 you shoved the Large Red Cube and its pallet off the black line. In Project 9 you stacked Small Red Cubes on top of it for Mission 5.
Mission 8’s bonus asks for a Small Red Cube on the Large Red Cube again — this time with the pallet on the dock. Plan Missions 2, 5, and 8 as one sequence rather than three separate problems, and check with your judges how the scoring overlaps.
| Run | M9 bonus | M18 base | M8 base | M8 bonus | Points |
|---|---|---|---|---|---|
| 1 | |||||
| 2 | |||||
| 3 | |||||
| 4 | |||||
| 5 |
| Mission part | Scored? | Points |
|---|---|---|
| Mission 9 — Bonus (Botguy out and on the floor) | 9 | |
| Mission 18 — Base (Botguy in the Loading Zone) | 11 | |
| Mission 8 — Base (pallet + cube on the dock) | 11 | |
| Mission 8 — Bonus (small red cube on top up there) | 9 | |
| My total | 40 |
These replace every timing number you have been carrying since Project 4.
| Measurement | Value |
|---|---|
| Ticks per inch | |
| Driving power I use | |
| My overshoot at that power | |
| Ticks for a 90° turn | |
| Ticks for a 180° turn | |
| Ticks from my starting box to the loading dock |
| I want the robot to… | The condition is |
|---|---|
| Drive forward until it has turned 2500 ticks | |
| Drive backward until it is back at zero | |
| Drive forward 8 inches, using my ticks per inch |
Your battery is half flat, so the robot drives slower. What happens to a run built on msleep()? What happens to a run built on ticks?
Ticks tell you how far the wheels turned — not how far the robot moved. Name a situation where those two are different.
You have now written the drive-a-set-distance code and the turn-90° code several times each, in several projects. What would you rather do than keep retyping them?
You have a robot that can measure. You also have a program that says the same twenty lines over and over.
In Project 12 — Teaching Your Robot New Moves, you give those twenty lines a name — and then you just say the name.
KIPR · Botball Explorer — Discovery Projects · © KISS Institute for Practical Robotics 1997–2026
When you are finished, press the button to turn in your work and save a copy.
KIPR · Botball Explorer · Discovery