Unit 3 · Big Idea 1
Meet the Servos
Student Lab · Calibrating an Arm and Claw
Student PIN:
Overview
Your robot can drive, sense, and follow lines — but it can’t yet touch the world. To stack cubes, it needs an arm and a claw. Those are run by servos: motors that move to an exact position and hold it. Today you’ll build a demobot arm and claw, learn to move each servo to a precise spot, and — most important — find the safe limits of your servos so you never damage them. Then you’ll try your first pick-up.
Core Insight
A servo doesn’t spin like a wheel — it goes to a position and holds. That precision is what lets a robot grab, lift, and place objects exactly.
By the end of this activity you will be able to:
- Enable and move a servo to an exact position with
enable_servoandset_servo_position. - Use the servo widget to find your arm and claw’s safe minimum and maximum.
- Explain why staying inside the safe range protects the servo from burning out.
- Write a sequence that opens, lowers, closes, and lifts — a first cube pick-up.
Build & Plug In the Servos
Wiring --- get this right before powering on
Plug the arm servo into servo 0 and the claw servo into servo port 3.
On each servo cord, the orange wire must be closest to the screen. Plugging it in backward can damage the servo or the — double-check before you power on.
Phase 1 — Concept: How a Servo Works
A motor spins freely. A servo is different: it turns to a specific position in its range and holds there. Think of a protractor — its arm can point to any angle and stay. A servo’s range is divided into numbered positions from 0 to 2047.
enable_servo(0); // turn on the servo on port 0
set_servo_position(0, 1024); // send it to position 1024 (the center)
The bigger the number, the farther it turns one way; the smaller, the farther the other way.
The moment you call enable_servo, that servo jumps to position 1024 (the center) — unless you’ve already told it to go somewhere else. So when your code first runs, expect the arm and claw to snap to their middle position. Plan for that, so the arm doesn’t swing into something.
Here’s the powerful part: a servo’s position number is a measurement. A bigger arm number lowers the arm, and a smaller arm number raises it. A bigger claw number means the claw is open a different amount. Instead of measuring how far the robot drove, today you measure how high the arm lifts and how far the claw opens — all by position value.
Phase 2 — Find the Arm’s Safe Range
⚠ This step protects your servo --- do it carefully
A servo can only turn so far before it hits a hard mechanical stop. If you command it past that stop, the motor keeps straining against the wall and can burn out. You must find the highest and lowest positions your arm can reach without forcing it, and never command outside them.
Use the servo widget
Open the Motors and widget and find the servo page. Select port 0 (the arm). Slowly move the position up and down. Watch and listen: stop the moment the arm reaches its physical limit — do not push it into a strain or buzzing sound.
Record the minimum safe value (arm all the way up) and the maximum safe value (arm all the way down). On this robot, lower servo values raise the arm and higher values lower it.
| Arm position | Value (0–2047) |
|---|---|
| Minimum safe value (arm up) — your ARM_MIN | |
| Maximum safe value (arm down) — your ARM_MAX | |
| Resting / centered position |
How did you know you’d reached the arm’s limit? What did you see or hear that told you to stop before forcing it?
Phase 3 — Find the Claw’s Safe Range
Same careful process, port 3
Select port 3 (the claw) in the servo widget. Slowly open and close it. Find the position where it’s open wide enough to fit around a cube, and the position where it’s closed snugly on the cube — without straining past either stop.
| Claw position | Value (0–2047) |
|---|---|
| Open wide (fits around cube) — your CLAW_OPEN | |
| Closed on the cube — your CLAW_SHUT |
A servo position is a measurement. In your own words, what does a bigger claw number mean physically? What does a bigger arm number mean?
Phase 4 — Build: Your First Pick-Up
⚠ Never command past your safe values
Every set_servo_position in your code must use a number between the safe values you found. If you type a number outside them, you risk burning out the servo. Use your ARM_MIN, ARM_MAX, CLAW_OPEN, and CLAW_SHUT — not random numbers.
Type your four safe values at the top, then build the grab sequence: open the claw, lower the arm, close on the cube, and lift. Each move gets a pause so the servo has time to arrive.
// Unit 3, Big Idea 1: Meet the Servos
// Name: _______________________ Date: ___________
#include <kipr/wombat.h>
// YOUR safe values from the widget: never command past these,
// or you can BURN OUT the servo by forcing it into a hard stop.
int ARM_MIN = ____; // minimum safe value (arm up)
int ARM_MAX = ____; // maximum safe value (arm down)
int CLAW_OPEN = ____; // safe open claw position
int CLAW_SHUT = ____; // safe closed-on-cube claw position
int main()
{
enable_servo(0); // arm servo on port 0
enable_servo(1); // claw servo on port 3
// (enabling sends each servo to 1024 unless told otherwise)
set_servo_position(3, CLAW_OPEN); // 1. open the claw
msleep(1000); // give the servo time to get there
set_servo_position(0, ARM_MAX); // 2. lower the arm to the cube
msleep(1000);
set_servo_position(3, CLAW_SHUT); // 3. close on the cube
msleep(1000);
set_servo_position(0, ARM_MIN); // 4. raise the cube up
msleep(1000);
return 0;
}About the msleep(1000): servos don’t move instantly, so you wait for each one to arrive before the next command. We use a full second for safety while you’re learning — once you know your servos, you can shorten it.
⚠ Hold the robot and watch the first run
Run this with the robot held still on a table, cube in reach. Watch each move happen. If anything strains, buzzes, or pushes against a stop, stop the program immediately and re-check your values.
Pick-Up Log
| Try | What happened at each step (open / lower / close / lift) | What you adjusted |
|---|---|---|
| 1 | ||
| 2 | ||
| 3 | ||
| 4 |
Did your robot pick up the cube? If a step didn’t work (claw missed, arm too low/high), which safe value did you adjust, and why?
Phase 5 — Measure the Motion
Servo positions are numbers, so you can measure your robot’s reach the same way you measured driving distance. Use your values to answer these.
| Measurement | Value |
|---|---|
| Arm travel = ARM_MAX − ARM_MIN (how far the arm swings) | |
| Claw travel = CLAW_OPEN − CLAW_SHUT (how far the claw moves) |
Which has more travel — your arm or your claw? Why might one need a bigger range of motion than the other?
Phase 6 — Connect: The AI Literacy Bridge
AI Literacy Thread
Intelligent systems must know the limits of their own bodies to act safely.
Before your robot could safely lift anything, you had to teach it the limits of its own arm and claw — how far they can go before they break. Every robot that acts on the world has this problem. A factory arm knows exactly how far each joint can bend; a surgical robot has hard limits built in so it can never over-extend. Knowing your own physical limits isn’t a weakness — it’s what makes safe, precise action possible. A system that doesn’t know its limits will eventually destroy itself.
Read each scenario. Think it through, then write your answer.
Why is commanding a servo past its hard stop dangerous? Connect this to why a robot must “know its own body.”
Your safe values are probably a little different from a neighbor’s, even with the same parts. Why must each robot find its own limits rather than sharing one set of numbers?
Phase 7 — Individual Reflection
Complete this section on your own.
1. How is a servo different from a regular motor? What does set_servo_position do?
2. What happens the moment you call enable_servo, and why do you need to plan for it?
3. Why is finding the safe minimum and maximum so important? What can happen if you ignore them?
4. Complete this in 2–3 sentences: “Intelligent systems must know the limits of their own bodies to act safely. This means that before a robot uses an arm, it must…”
Extension Challenges
Finished early? Try one or more of these.
Extension A — Set It Down Gently
- Add steps to lower the arm and open the claw to place the cube back down. Does the order matter? Test it.
Extension B — How Slow Can the Pause Go?
- Shorten the
msleepafter each move (try 700, then 500). What’s the shortest pause where the servo still fully arrives before the next move? What happens if it’s too short?
Extension C — A Middle Height
- Find an arm value between your min and max that holds the cube at a useful “carry” height. Why might you want to carry a cube partway up instead of fully raised?
Extension D — Looking Ahead: Reusing These Moves
- You’ll use “open,” “close,” “raise,” and “lower” over and over in future missions. How could turning each into its own make stacking cubes easier later? (We’ll build toward a shared .)
Extension E — What’s the Computer, What’s the Peripheral?
- The Wombat controller has a processor running your compiled program, memory holding that program while it runs, and things it commands — like your servos. Which parts of your robot are “the computer,” and which are peripherals it’s controlling?
- Where does a sensor fit into that picture?
Extension F — Compiled, Typed, and Running on Something
- Extension E called your program “compiled.” Look up what compiling means, and contrast it with an interpreted language (like Python) that runs line-by-line instead. Which would you guess is faster for a robot that needs to react in real time, and why?
- C is a strongly typed language — every has a fixed type (double, int, char) that can’t silently change. Some languages are more loosely typed, letting a variable hold different kinds of values over its life. What’s one bug that strong typing might catch for you automatically that a loosely-typed language wouldn’t?
- Your program also runs on top of an operating system on the Wombat controller. Name one thing you’d guess the OS is doing while your program runs, besides running your program.
When you are finished, press the button to turn in your work and save a copy.
KIPR · Botball Explorer · Unit 3 Big Idea 1 — Student Lab