KIPR · Botball Explorer
Activity Sections

Discovery · Coding Project 7

Your Robot’s Arm

A motor that goes to a place instead of just going. Seven points for touching one plastic guy.

Project
Coding Project 7
Strand
Coding
Phase
Make It Grab
Time
One class period
What You Are Doing
Wiring up a , finding its safe positions, and using an arm to reach into the and touch Botguy.
Mission Anchor
Mission 9 — Recover Botguy (base)
Before You Start
Project 6 — and your arm must be built. The build lives in the Systems strand.
What You Need
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 Submit & Download to turn in your work and save a copy.

Try It — A Different Kind of Motor

Hold a wheel motor in one hand and a in the other. They look similar. They are not.

Wheel motorServo
WiresTwo — red and blackThree — orange, red, brown
PlugTwo metal prongsBlack plastic plug
How far it turnsRound and round, foreverAbout half a circle, then stops
What you tell itHow hard to pushWhere to go

Plug it in — the wire order matters

Servo wires --- check the colours before you push the plug in.
There are four servo , numbered 0 to 3. Each one has three pins, and putting the plug in backwards will not work.

Code / partWhat it means
S — orange wireSignal. This is the wire that carries the position you asked for.
+ — red wirePower.
− — brown wireGround. Remember it as: the ground is down, and down is negative.

Plug your servo into port 0, brown wire toward the minus side.

Try the widget before you write anything

On the Wombat’s Home Screen, tap Servos. Enable port 0 and drag the slider slowly.

What does the arm do as you drag?

Now let go of the slider and try to push the arm with your finger. What happens?

It Pushes Back

A servo does not just move to a position — it holds that position and fights anything that tries to move it. That is why it can lift something and keep holding it there.

Learn It — Positions, Not Powers

A servo's range is like a protractor --- 180° split into positions 0 to 2047.
A servo turns about 180°, and that half circle is divided into 2048 positions, numbered 0 to 2047.

Notice that we are counting from zero again — same as the motor ports.

Position 1024 is the middle. That is where a servo goes by default.

⚠ Never Below 150 or Above 1900

The numbers go to 2047, but your servo physically cannot reach the ends. Sending it past its limit makes it strain against its own stop, and it will burn out. A burnt servo does not come back.

Stay between 150 and 1900. Always.

⚠ Servo command range vs classroom safe limits

The set_servo_position() command accepts positions 0 to 2047 (about 180°). Classroom hardware must stay in the safe band 150–1900, with center near 1024. Sending commands into the burn zones (below 150 or above 1900) can destroy the servo.

The four commands

Code / partWhat it means
enable_servos();Turns on all four servo ports. Nothing works until you call this.
set_servo_position(0, 800);Sends the servo in port 0 to position 800. Two — port first, then position.
msleep(500);Gives the servo time to actually get there. Not optional.
disable_servos();Turns the servo ports off at the end of your program.

Why msleep Again?

Same reason as the wheel motors. set_servo_position() tells the servo to start moving — it does not wait for it to arrive. Without an msleep(), the next line runs while the arm is still halfway there.

The gotcha that catches everybody

When you call enable_servos(), every servo immediately jumps to whatever position it was in last time. Which might be anywhere.

If your arm was down when you last ran a program, it will slam down again the instant your new program enables the servos — possibly into the field, or into a cube, or into your hand.

The Preset Trick

Call set_servo_position() before enable_servos(). The servo then wakes up already knowing where to go, and moves there instead of to its old position.

// Risky: arm snaps to last position
enable_servos();
set_servo_position(0, 524);

// Better: arm starts at 524
set_servo_position(0, 524);
enable_servos();

Write your positions down

Position numbers mean nothing on their own. set_servo_position(0, 1746); tells you nothing about what the arm is doing. every one:

// up         = 524
// horizontal = 1566
// down       = 1746

Use the format name = number. There is a reason for that — in Project 9 those names stop being comments and become part of the program.

Where you are headed

Watch Mission 9 video

Bonus Mission

9 points Live judged

Botguy is outside the enclosure AND is touching the warehouse floor.

Scores

  • A robot is touching Botguy.
  • Botguy is completely outside the enclosure and touching the warehouse floor.
  • Botguy is touching the warehouse floor while being held by a robot.

Does Not Score

  • A robot is near Botguy but not touching him.
  • Botguy is touching the warehouse floor but still touching the enclosure.
  • Botguy is removed from the enclosure but not touching the warehouse floor.
Seven points for one touch. It is the best points-per-effort deal on the field — as long as you actually make contact.

Do It — Reach and Touch

The servo ports on the Wombat.
A servo plugged into port 0.

Step 1 — Center the horn first

The servo page on the Wombat.
Drag the slider to test a servo before you write any code.
Your servo can only reach half a circle — but looking at it, you cannot tell which half. Fix that mechanically before you write any code.

  • Unscrew the servo horn.
  • In the Servo Widget, enable the servo and set it to 1024.
  • Put the horn back on pointing at the middle of the range you actually want.
  • Check both directions with the widget. Screw it back down when it is right.

Skip this and you will spend the rest of the project fighting an arm that runs out of travel halfway through a move.

Step 2 — Find your three positions

Using the widget, find the number for each of these and write it down. Stay inside 150–1900.

Arm positionNumberWhat it looks like
Up (straight up)
Horizontal (level)
Down (not touching the floor)

⚠ Down Means Nearly Down

Do not find a “down” that presses the arm into the floor. The servo will keep straining to reach a position it cannot get to, and that is exactly how servos die.

Step 3 — The Wave

Create a new project called Wave. Move the arm to all three positions with a one-second pause between each. Put your position comments at the top.

#include <kipr/wombat.h>

int main ()
{
	// up         = 524
	// horizontal = 1566
	// down       = 1746

	// Preset to down
	set_servo_position(0, 1746);
	enable_servos();
	msleep(1000);

	// Horizontal
	set_servo_position(0, 1566);
	msleep(1000);

	// Up
	set_servo_position(0, 524);
	msleep(1000);

	disable_servos();
	return 0;
}

Use your numbers, not these. and run.

Step 4 — Prove the msleep matters

Delete all three msleep() lines. Compile. Run. Watch closely.

What did the arm do?

Put them back.

Step 5 — Prove the preset trick matters

Run your Wave program so the arm finishes up. Now swap lines 9 and 10 so enable_servos() comes first, and run it again.

What did the arm do the instant the program started?

Why could that be a problem in the middle of a match?

Put it back the safe way round.

Step 6 — Drive and touch

Create a new project called Reach. Practice away from the field first: put any object a short drive away, then drive to it and touch it with the arm.

Two rules, borrowed from how the mission works:

  • The arm must start up and move down to touch. No driving around with the arm already out front.
  • Touch it with the arm only — not with the robot’s body.
// 1. Arm starts up
// 2. Drive to the object
// 3. Stop
// 4. Lower the arm to touch it
// 5. Raise the arm again

Step 7 — Mission 9 — touch Botguy for 7 points

Onto the field. Create a new project called Botguy.

Botguy is inside the enclosure. Your robot has to reach in and make contact — direct contact, arm to Botguy.

TryWhat I changedDid the arm reach him?
1
2
3
4
Which was harder — getting the robot into position, or getting the arm to the right height?

Step 8 — Run it five times

RunTouched Botguy?
1
2
3
4
5

Score It — Checkpoint

My score

Mission partScored?Points
Mission 9 — Base (robot Botguy)7
My total7

My servo card

Keep these next to your driving numbers. Everything from here uses them.

SettingValue
Servo port my arm is in
Arm up position
Arm horizontal position
Arm down position
Arm position for touching Botguy
msleep needed for a full up-to-down move

Can you do it again?

Think about it

A wheel motor takes a power. A servo takes a position. Why does an arm need a position and a wheel does not?

Your position numbers are scattered through your program as bare numbers with comments next to them. If you rebuilt your arm slightly differently tomorrow, how many places would you have to change?

You can touch Botguy but you cannot get him out of the enclosure. What exactly can a claw do that a single arm cannot?

Next

In Project 8 — Arm and Claw Together, a second servo joins the first. Two servos working as one system means you can finally grab, carry, and release — and a whole set of missions opens up at once.

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