Teacher's Companion: LEGO SPIKE Prime
A classroom-first teacher companion for LEGO SPIKE Prime. This tool walks non-coder teachers through a 14-week robotics curriculum using metaphors, board-work prompts, and fully written teacher scripts. Each week focuses on a core robotics or Python concept (movement, sensors, loops, functions, and strategy), with ready-to-run code examples and 'if things go wrong' rescue tips.
You don't need to be a coder.
This guide is your secret weapon. It translates every complex Python concept into a simple metaphor you can tell 5th graders.
The "Yellow Bubble" Rule
Whenever you see a yellow box, read it out loud. It is a pre-written script designed to explain hard concepts simply.
Interactive Code
Don't just stare at code. Scroll through the examples in this guide. Each snippet is paired with a plain-English explanation and "If things go wrong" rescue tips.
The Brain Surgery
At a glance
Big idea: The yellow Hub is a brain that is currently "asleep". Students will wake it up using a tiny Python program.
- Robotics experience needed: None. You will follow the script on this page.
- Python experience needed: None. Students only type a few short lines that you can read out loud.
- Main outcomes: Battery inserted, Hub connected over Bluetooth, first program runs successfully on the Hub display.
Before class (teacher prep)
- Make sure each kit has a Hub, battery, charging cable, and at least two motors (they will be used more in Week 2).
- Charge the Hubs or have them plugged in so students are not blocked by low battery.
- Open the LEGO SPIKE App 3 on your computer once and confirm that you can create a Python project.
- Decide student groups (2-3 per kit) so you can assign clear roles later (Builder, Coder, Cable Manager).
Board work & story (10-15 mins)
Use this sequence even if you have never coded before. Just copy the sentences and write the key words on the board.
- Tell the story: "This yellow brick is a $300 brain. Right now, it is in a coma. Today we will perform brain surgery to wake it up using a language called Python."
- Introduce libraries: Write on the board:
from hub import light_matrixand say: "Python is an empty toolbox. We must import the tools we need. Today we are importing the light display on the Hub." - Explain the goal: "Our mission is to make the Hub count down 5-4-3-2-1 and then show a happy face. That tells us the brain is awake and listening."
Phase 1 β Kit hygiene (15-20 mins)
Before opening laptops, get control of the LEGO pieces so they do not explode across the room.
"I am the Floor Shark. Any LEGO piece that touches the floor belongs to me. To get it back, you have to answer a Python question. Keep your pieces on the table!"
- Have groups quickly sort pieces into the main tray sections (you do not need perfect sorting).
- Walk around once and praise teams that are keeping pieces in the trays.
- Remind them that organized kits = more building time later.
Phase 2 β The first script (30-40 mins)
Students will now create their first Python program. You can follow these steps word-for-word.
- Connect the Hub: Ask students to insert the battery into the Hub, turn it on, and connect via Bluetooth inside the SPIKE app (follow on-screen prompts).
- Create a Python project: In the SPIKE app, choose a new project and pick the Python option (not word blocks).
- Type the code together: Point to the code example below. Have students type each line slowly. Read the short explanation under the code if they get stuck.
- Run the program: Press the Run button in the SPIKE app. Check that the word "Hello" appears on the Hub.
- Extension (if time): Change the word to "54321" and then show a happy face, as in the full curriculum document. Celebrate the first successful "brain surgery".
The First Script: Waking the Robot
from hub import light_matrix
import runloop
async def main():
# Countdown
await light_matrix.write("54321")
await runloop.sleep_ms(1000)
# Show Life
await light_matrix.show_image(light_matrix.IMAGE_HAPPY)
runloop.run(main())
What each part does
- Lines 1-2: Import the tools you need: the Hub display (
light_matrix) and the timing tool (runloop). -
async def main():Creates a "mission" calledmain. Everything indented underneath is part of that mission. - Countdown:
await light_matrix.write("54321")writes the numbers on the Hub. Theawaitkeyword means "finish this before moving on". - Pause:
await runloop.sleep_ms(1000)waits for 1 second (1000 milliseconds) so students can see the countdown. - Happy face:
await light_matrix.show_image(light_matrix.IMAGE_HAPPY)shows a built-in happy face image on the Hub screen. - Launch:
runloop.run(main())actually starts the mission. Without this line, nothing happens.
If things go wrong
- Hub won't connect: Turn the Hub off and back on, then try the Bluetooth connection again in the SPIKE app. Move other groups a little farther away if there is interference.
- Code won't run: Check that all lines start at the left edge except the lines under
async def main():. Those indented lines must line up under each other. Python is very strict about spaces. - Students are stuck typing: Let one student read the code aloud while the partner types. Remind them they can copy from the board and from this page exactly.
The Handshake (Initialization)
At a glance
Big idea: Students build the first driving base and teach the brain (Hub) to recognize its legs (motors) so it can drive in a straight line.
- Robotics experience needed: None. Students follow the build instructions and a simple script.
- Python experience needed: Very little. They will copy one short program together.
- Main outcomes: Drive Base 1 is built, motors are paired with the Hub, and the robot completes a simple drag race (forward, pause, backward).
Before class (teacher prep)
- Bookmark the LEGO build for Drive Base 1 (Competition Ready β Training Camp 1: Driving Around).
- Check that each robot kit has two motors and a Hub with enough battery.
- Decide where the "drag strip" will be: tape a straight lane (~1 metre) on the floor or table.
- Plan for pairs or groups of three so you can assign clear roles (Engineer, Mechanic, Coder).
Board work & story (10β15 mins)
Use this script to explain the handshake, even if you are new to coding.
"The Hub is smart, but it is blind. It doesn't know it has legs. If we tell it to 'Drive', it will say 'With what?'. We have to introduce the Brain to the Wheels. We call this The Handshake."
-
On the board, write
motor_pair.pair(motor_pair.PAIR_1, port.C, port.D)and circleCandD. Explain: "We are telling the brain which ports are the wheels." - Draw the Hub and label ports C and D. Ask students to trace the cables on their own robot to check that C is left and D is right.
- Explain: "Once the handshake is done, we can say 'Drive!' and both wheels move together like a threeβlegged race team."
Phase 1 β The build (40β60 mins)
Students build Drive Base 1 from the LEGO instructions.
"Welcome, Pit Crews. Today isn't about coding; it's about building a machine that can survive a drag race. You have 60 minutes. A loose wheel means disqualification on the track. Go!"
- Assign roles to reduce arguing: Chief Engineer (finds pieces) and Mechanic (assembles). Swap every 15 minutes.
- Walk around and check that wheels are firmly attached and cables are neat.
Phase 2 β The drag race code (30β40 mins)
Now that the robot has legs, give it a simple mission: drive forward 50cm, pause, then drive back.
- Confirm motors are plugged into ports C (left) and D (right).
- Create a new Python project in the SPIKE app.
- Type the code below together with the class, one line at a time.
- Place the robot at the start of the taped drag strip and run the program.
from hub import port
import motor_pair, runloop
async def main():
# Setup
motor_pair.pair(motor_pair.PAIR_1, port.C, port.D)
# Drive forward 50cm
await motor_pair.move_for_amount(motor_pair.PAIR_1, 50, motor_pair.UNIT_CM, 0, velocity=360)
# Pause for 1 second
await runloop.sleep_ms(1000)
# Drive backward 50cm
await motor_pair.move_for_amount(motor_pair.PAIR_1, 50, motor_pair.UNIT_CM, 0, velocity=-360)
runloop.run(main())
What each part does
- Imports:
from hub import portandimport motor_pair, runloopbring in the tools for wheel control and timing. - Handshake:
motor_pair.pair(...)tells the Hub which ports are the left and right wheels (C and D). - Forward / backward:
move_for_amount(..., 50, motor_pair.UNIT_CM, 0, velocity=...)drives a distance in centimeters with steering0(straight). Positive velocity is forward; negative is backward. - Pause:
runloop.sleep_ms(1000)waits 1 second so students can see the robot stop before reversing. - Launch:
runloop.run(main())starts the mission. Without it, nothing happens.
If things go wrong ("Spin of Doom")
- Robot spins in a circle: One motor cable is in the wrong port. Ask students to trace the wire with a finger from the motor to the Hub and fix the letters in the code or the ports so they match.
- Robot doesn't move: Make sure
motor_pair.pair(...)is above the movement lines and that the Hub is turned on. - Error "NameError: motor_pair is not defined": Add
import motor_pairat the top of the file.
Navigation (Loops)
At a glance
Big idea: Instead of writing the same movement over and over, students use a loop to make the robot drive in a square.
- Robotics experience needed: Students already have Drive Base 1 from Week 2.
- Python experience needed: They know basic movement; this week introduces
forloops. - Main outcomes: Students write a loop to drive 4 equal sides and adjust the turning amount (around 176 degrees) to get clean 90Β° corners.
Before class (teacher prep)
- Make sure robots are still built as Drive Base 1 with motors on ports C and D.
- Clear a square area on the floor or table for testing. Optional: tape a large square route.
- Have a ruler or measuring tape handy so students can estimate 20cm segments.
Board work & story (10β15 mins)
"I want you to clap your hands 4 times. Did I say 'Clap, Clap, Clap, Clap'? No. That's exhausting. I said 'Clap times 4'. In Python, if you write the same code twice, you are working too hard. We use a Loop."
- On the board, draw a square path (four equal sides) and label each side "Forward" and each corner "Turn".
-
Write a mini-loop on the board:
for i in range(4):and explain that this means "repeat the next steps 4 times". - Explain that turning the wheel 90 degrees does not turn the robot 90 degrees; students must experiment to find the magic number (around 176).
Phase 1 β The turning mystery (20β30 mins)
Goal: Help students feel the difference between wheel degrees and robot degrees.
- Ask students: "If I turn the wheel 90 degrees, will the robot turn 90 degrees?" Let them guess.
- Have teams experiment with different turning amounts (e.g., 90, 140, 176 degrees) and observe how far the robot turns.
- Collect answers and highlight that around 176 degrees of wheel turn β 90Β° robot turn for most builds.
Phase 2 β The square challenge (40β50 mins)
Mission: Drive in a perfect square: forward, turn right, repeat 4 times.
- Have students sketch the square path and label each side 20cm.
- Explain that the loop will run 4 times: drive forward, then turn, then repeat.
- Students type the full program below, then tweak the turning amount until the robot ends where it started.
from hub import port
import motor_pair, runloop
async def main():
motor_pair.pair(motor_pair.PAIR_1, port.C, port.D)
for i in range(4):
# Forward 20cm
await motor_pair.move_for_amount(motor_pair.PAIR_1, 20, motor_pair.UNIT_CM, 0, velocity=360)
# Turn (students can tune this value, e.g., 176 degrees)
await motor_pair.move_for_amount(motor_pair.PAIR_1, 176, motor_pair.UNIT_DEGREES, 100, velocity=360)
runloop.run(main())
What each part does
- Loop header:
for i in range(4):means "repeat the indented steps 4 times" (one for each side of the square). - Forward motion:
move_for_amount(..., 20, motor_pair.UNIT_CM,...)drives about 20cm for each side. - Turn:
move_for_amount(..., 176, motor_pair.UNIT_DEGREES, 100,...)spins the wheels so the robot turns roughly 90Β°. Students adjust 176 until the square closes cleanly. - Steering = 100: This is a "spot turn" where the wheels spin in opposite directions so the robot pivots on the spot.
If things go wrong
- Square doesn't close: Adjust the turning amount (e.g., try 170, 176, 182) until the robot ends close to the starting point.
- Robot turns the wrong way: Change the steering from
100to-100(right vs left turn). - Robot only moves once: Check that the forward and turn lines are indented under the
forloop.
Steering (The Slalom)
At a glance
Big idea: Steering is not just left or right. It is a dial that controls how sharply the robot turns.
- Robotics experience needed: Students already have a working Drive Base from Week 2β3.
- Python experience needed: They can already move forward and turn. This week they adjust the
steeringparameter to drive in curves. - Main outcomes: Students understand steering values (0, 20, 50, 100) and program a slalom path weaving between cups without touching them.
Before class (teacher prep)
- Ensure all robots are built as Drive Base 1 with motors on ports C and D.
- Prepare at least 3 plastic cups or small objects per group to use as slalom cones.
- Mark a straight lane with tape and place cups in a line with enough spacing to weave between them.
Board work & steering story (10β15 mins)
Use this explanation to introduce steering like a volume knob.
"We know Steering=0 is straight. We know Steering=100 is a sharp spin. But what happens if we pick 50? Or 20? Today we aren't turning corners; we are driving in arcs."
Draw this table on the board:
The "Steering Knob" Cheat Sheet
Phase 1 β Steering practice (20β30 mins)
Goal: Let students see how different steering values change the path.
- Have students drive the robot straight with steering
0for a short distance. -
Repeat with steering
20, then50, then100, and have them describe each path (gentle curve vs pivot vs spin).
Phase 2 β The slalom challenge (40β50 mins)
Mission: Program the robot to weave around the cups in an S-shape without knocking them over.
- Place three cups in a straight line along the lane.
- Students use two curves: curve right (positive steering) then curve left (negative steering).
- They adjust the distance and steering until the robot passes between the cups cleanly.
from hub import port
import motor_pair, runloop
async def main():
motor_pair.pair(motor_pair.PAIR_1, port.C, port.D)
# Curve right
await motor_pair.move_for_amount(motor_pair.PAIR_1, 500, motor_pair.UNIT_DEGREES, 50, velocity=360)
# Curve left
await motor_pair.move_for_amount(motor_pair.PAIR_1, 500, motor_pair.UNIT_DEGREES, -50, velocity=360)
runloop.run(main())
What each part does
- Steering: The third argument (
50or-50) controls how sharply you turn and in which direction. - Distance:
500withUNIT_DEGREEScontrols how long the curve lasts; students can increase or decrease this to make longer or shorter arcs. - Velocity:
velocity=360sets the speed. Slower speeds make it easier to pass between the cups.
If things go wrong
- Robot hits the cups: Reduce the steering (e.g., from
50to30) or the distance (e.g., from500to350). - Robot turns too late or too early: Adjust the first curve distance or add a short straight drive before curving.
- Robot spins instead of curving: Check that steering is not
100. Values near 100 create spot turns, not arcs.
Force Sensor (Touch)
At a glance
Big idea: The robot needs a sense of touch. With a Force Sensor and a while loop, it can bump into a wall, stop, beep, and back up.
- Robotics experience needed: Students now upgrade to Drive Base 2 with a Force Sensor mounted on the front.
- Python experience needed: They already know movement; this week introduces the
whileloop for "wait until" logic. - Main outcomes: Robot drives forward, waits for a collision, then stops, beeps, and reverses safely.
Before class (teacher prep)
- Upgrade robots to Drive Base 2 following the LEGO instructions (Competition Ready β Training Camp 2).
- Mount the Force Sensor on the front and plug it into Port E.
- Set up a solid wall or box for robots to bump into (not a student!).
Concept & story (10β15 mins)
"Close your eyes. Walk forward slowly. How do you know when to stop? You feel the wall. Right now, our robot is numb. We need to give it a central nervous system."
- Show the Force Sensor and press it with your finger. Explain: "This is the robot's fingertip. When it is pressed, Python can check that."
-
On the board, write:
while not force_sensor.is_pressed(port.E):and explain that this means "keep waiting until the button is pressed".
Phase 1 β Bumper car activity (40β50 mins)
Mission: Robot drives forward until it hits the wall, then stops, beeps, and reverses.
- Students place the robot a safe distance from the wall with the Force Sensor pointing forward.
- They type the full program below and predict what will happen when the robot touches the wall.
- Run the program and have students watch for the moment the sensor is pressed.
from hub import port, sound
import motor_pair, force_sensor, runloop
async def main():
motor_pair.pair(motor_pair.PAIR_1, port.C, port.D)
# Start moving forward
motor_pair.move(motor_pair.PAIR_1, 0, velocity=360)
# Wait for impact
while not force_sensor.is_pressed(port.E):
await runloop.sleep_ms(10)
# On collision: stop, beep, and back up
motor_pair.stop(motor_pair.PAIR_1)
await sound.beep()
await motor_pair.move_for_amount(motor_pair.PAIR_1, 10, motor_pair.UNIT_CM, 0, velocity=-360)
runloop.run(main())
What each part does
- Continuous driving:
motor_pair.move(...)starts the robot and keeps it moving until you tell it to stop. - Wait loop:
while not force_sensor.is_pressed(port.E):means "keep looping while the button is not pressed". - Pause between checks:
await runloop.sleep_ms(10)checks the sensor every 10 milliseconds so the program does not freeze the Hub. - Recovery: After the crash, the robot stops, beeps, and reverses 10cm away from the wall.
If things go wrong
- Robot never stops: Check that the Force Sensor is really on Port E and that students pushed it in
firmly. Make sure the
whileline usesport.E, not another letter. - Robot stops immediately: The sensor might already be pressed against the wall or a LEGO piece. Pull the robot back a little and try again.
- Error about
force_sensor: Check thatimport force_sensoris at the top of the file.
Distance Sensor (Bat Vision)
At a glance
Big idea: The robot can "see" how far away walls are using sound, like a bat. We teach it a safety rule: if distance < 10cm, stop.
- Robotics experience needed: Drive Base 2 with Distance Sensor attached to the front (usually Port F).
- Python experience needed: Students know
whileloops from Week 5; this week adds a comparison (<) and the special value-1for "no object". - Main outcomes: Robot drives toward a wall and stops itself at about 10cm before crashing.
Before class (teacher prep)
- Upgrade each robot to Drive Base 2 and mount the Distance Sensor on the front (Port F).
- Set up a solid wall or box as the target. Avoid soft surfaces like pillows or clothing.
- Have a ruler or tape measure ready so students can see what 10cm looks like.
Concept & physics story (10β15 mins)
Topic: Echolocation & thresholds.
"Bats don't need to touch a wall to know it's there. They use sound. Our robot has ultrasonic eyes. We need to teach it: 'If distance is LESS THAN 10cm, STOP.'"
Common Failure: The Sweater
If a student stands in front of the robot wearing a wool sweater, the robot might crash. Soft clothes absorb sound, so the echo never comes back. Use a hard book or box as the obstacle.
Phase 1 β Measuring distance (15β20 mins)
Let students see the numbers from the Distance Sensor.
- Show how the sensor returns numbers in centimeters and
-1when it sees "infinity" (nothing). - Have them move the robot closer and farther from the wall and call out the distances.
Phase 2 β Don't crash (40β50 mins)
Mission: Robot drives toward the wall and stops at around 10cm.
- Place the robot facing the wall with at least 50β80cm of space.
- Students type the full program below.
- They test and adjust the 10cm threshold if needed for their surface.
from hub import port
import motor_pair, distance_sensor, runloop
async def main():
motor_pair.pair(motor_pair.PAIR_1, port.C, port.D)
# Drive forward until it's too close
motor_pair.move(motor_pair.PAIR_1, 0, velocity=360)
while True:
dist = distance_sensor.get_distance_cm(port.F)
if dist != -1 and dist < 10:
# Too close! Stop and break out of the loop
motor_pair.stop(motor_pair.PAIR_1)
break
await runloop.sleep_ms(10)
runloop.run(main())
What each part does
- Distance reading:
distance_sensor.get_distance_cm(port.F)returns the distance in centimeters, or-1if nothing is detected. - Threshold:
dist < 10defines the "danger zone" near the wall. - Error check:
dist != -1makes sure we ignore the "infinity" value. - Loop:
while Truekeeps checking until the robot is too close, then breaks out.
If things go wrong
- Robot doesn't stop: Check that the sensor is plugged into Port F and pointed at a hard surface. Increase the threshold to 15cm if the floor is very shiny.
- Distance always -1: The sensor may be angled away from the wall or looking at something too soft to reflect sound.
- Error about
distance_sensor: Make sureimport distance_sensoris at the top of the file.
Color Sensor (Decisions)
At a glance
Big idea: The robot reads colors and uses if / elif decisions to follow simple traffic rules.
- Robotics experience needed: Same drive base; add a Color Sensor pointing at the floor (usually Port A).
- Python experience needed: Students know loops; this week they combine a
while Trueloop withif / elifdecisions. - Main outcomes: Robot drives over green and red patches, speeding up on green and stopping on red.
Before class (teacher prep)
- Attach the Color Sensor pointing down and plug it into Port A.
- Tape pieces of green and red paper to the floor or table where the robot will drive.
Logic story (10β15 mins)
"We are teaching the robot to follow laws. Green means Turbo Boost. Red means Stop. This is called an IF / ELSE statement."
- On the board, draw a simple tree: "Is it GREEN?" β Go Fast. "Else, is it RED?" β Stop.
- Explain that the robot checks one condition at a time in order.
Phase 1 β Traffic school activity (40β50 mins)
Mission: Robot drives slowly until it sees green or red.
- Students place green and red patches along the robot's path.
- They type the program below and test whether the robot speeds up on green and stops on red.
from hub import port
import motor_pair, color_sensor, runloop
async def main():
motor_pair.pair(motor_pair.PAIR_1, port.C, port.D)
while True:
color = color_sensor.get_color(port.A)
if color == color_sensor.GREEN:
# Turbo boost on green
motor_pair.move(motor_pair.PAIR_1, 0, velocity=500)
elif color == color_sensor.RED:
# Full stop on red
motor_pair.stop(motor_pair.PAIR_1)
await runloop.sleep_ms(50)
runloop.run(main())
What each part does
- Color reading:
get_color(port.A)returns a constant likecolor_sensor.REDorcolor_sensor.GREEN. - Decision:
if ... elif ...checks for green first, then red. - Loop:
while Truekeeps checking colors for as long as the robot is running.
If things go wrong
- Robot ignores colors: Check that the sensor is close enough to the floor and pointing at the paper, and that you are really using Port A in the code.
- Robot always goes fast: The sensor may be reading green all the time. Move the patches farther apart or slow down the robot.
Line Following (The Wiggle)
At a glance
Big idea: Line following is the "holy grail" skill. The robot does not see a line; it only sees brightness and constantly corrects left/right to stay on the edge.
- Robotics experience needed: Same drive base and Color Sensor as Week 7.
- Python experience needed: Students are comfortable with loops and
if. This week they tune thresholds. - Main outcomes: Robot follows a curvy black tape line by "wiggling" around its edge.
Before class (teacher prep)
- Lay a long, curved strip of black electrical tape on a light-coloured floor or board.
- Position the Color Sensor so it watches the tape from a few millimetres above the surface.
The Hardest Concept of the Term
Students think the robot sees a line. It doesn't. It sees "Bright" and "Dark".
We don't drive ON the line. We drive on the EDGE.
The Wiggle Algorithm:
- Am I on White (Bright)? β I'm falling off the left! Turn Right.
- Am I on Black (Dark)? β I'm falling off the right! Turn Left.
- Result: The robot wiggles back and forth along the edge.
Phase 1 β Wiggle demo (15β20 mins)
- Walk along a tape line and act out the algorithm: "Too bright β turn right. Too dark β turn left." Have students say it with you.
- Explain that the robot repeats this check many times per second.
Phase 2 β Line following mission (40β50 mins)
Mission: Follow a curvy tape line from start to finish without leaving it.
- Students place the robot so the Color Sensor sits over the edge of the black tape.
- They type the full line-following program below.
- They test, then tweak the threshold value (50) if their surface is lighter or darker.
from hub import port
import motor_pair, color_sensor, runloop
async def main():
motor_pair.pair(motor_pair.PAIR_1, port.C, port.D)
while True:
light = color_sensor.get_reflection(port.A)
# 50 is usually the midpoint between white (100) and black (0)
if light < 50:
# See dark β turn toward white
motor_pair.move(motor_pair.PAIR_1, 0, velocity=150, steering=50)
else:
# See bright β turn toward black
motor_pair.move(motor_pair.PAIR_1, 0, velocity=150, steering=-50)
await runloop.sleep_ms(10)
runloop.run(main())
What each part does
- Reflection value:
get_reflection()returns a brightness number from 0 (black) to 100 (white). - Threshold:
50is a starting guess for the "edge" between floor and tape. Students can change it to 40 or 60 if needed. - Steering:
50and-50gently steer toward one side or the other instead of making sharp turns.
If things go wrong
- Robot leaves the line: Lower the speed (e.g.,
velocity=120) or increase the steering values slightly. - Robot oscillates too much: Reduce steering (e.g., from
50to30) to make smoother corrections. - Sensor doesn't see the tape: Ensure the tape is really black and the floor is lighter, and that the sensor is close enough to the surface.
The Mechanical Build
At a glance
Big idea: The robot transforms into an advanced drive base with gears and an arm (Drive Base 3).
- Robotics experience needed: Students are familiar with Drive Base 1β2 builds.
- Python experience needed: None new this week. Focus is on careful building.
- Main outcomes: Drive Base 3 is fully built with good cable management and working gears.
Before class (teacher prep)
- Bookmark the LEGO instructions for Drive Base 3 (Competition Ready β Training Camp 4).
- Ensure each kit has all beams, gears, and the extra motor required for the arm.
- Plan enough time: this is a long build (up to 90 minutes).
Story & expectations (10 mins)
"We are no longer just observers. We are engineers. Today we disassemble our scout and build a machine that can move the world. This build is complex. Patience is key."
- Explain that today's success is a strong, reliable build, not code.
- Encourage teams to slow down and double-check each step in the instructions.
Phase 1 β The big build (60β90 mins)
- Have teams carefully dismantle their old drive base and sort useful parts.
- While they build, ask them to count the teeth on key gears and guess what changing gear ratios might do to speed/strength.
- Check that cables are neat and not wrapped tightly around moving parts.
The Claw (Single Motors)
At a glance
Big idea: The arm is not a pair of wheels. It is a single motor we control directly using degrees.
- Robotics experience needed: Drive Base 3 from Week 9, with an arm on Port E.
- Python experience needed: Students learn to use
motor.run_for_degrees()and combine motion with the claw. - Main outcomes: Robot can raise/lower the arm to grab and place an object.
Before class (teacher prep)
- Confirm the arm motor is plugged into Port E.
- Prepare a small brick and a raised surface (like a book) to act as the drop-off spot.
Concept story (10β15 mins)
"The Arm is not a wheel. We don't pair it. We talk to it directly. We also don't use 'seconds' or 'cm'. We use Degrees. Like an elbow, it has a limit. If you force it too far, it breaks."
-
On the board, write:
await motor.run_for_degrees(port.E, 90, velocity=300)and explain that this is like bending an elbow 90 degrees.
Phase 1 β Forklift mission (40β50 mins)
Mission: Start with the arm up, drive to a brick, lower the arm to grab it, lift it, drive forward, and place it on a book.
- Have students place a brick in front of the robot and a book a short distance away.
- They type the full program below, then fine-tune degrees to match their specific arm build.
from hub import port
import motor_pair, motor, runloop
async def main():
# Pair the drive motors
motor_pair.pair(motor_pair.PAIR_1, port.C, port.D)
# Lower arm to grab (tune degrees for your build)
await motor.run_for_degrees(port.E, -90, velocity=300)
# Drive forward to the drop-off
await motor_pair.move_for_amount(motor_pair.PAIR_1, 20, motor_pair.UNIT_CM, 0, velocity=360)
# Lift arm to place
await motor.run_for_degrees(port.E, 90, velocity=300)
runloop.run(main())
What each part does
- Single motor control:
motor.run_for_degrees(port.E,...)moves only the arm, not the wheels. - Degrees: Positive values raise the arm; negative values lower it (depending on how it was built).
- Drive and arm together: Students are now combining drive code with arm code in a single mission.
If things go wrong
- Arm hits the robot or table: Reduce the degrees (e.g., 60 instead of 90) and re-test.
- Arm moves backwards from what you expect: Swap the sign (+/-) on the degrees.
- Error about
motor: Make sureimport motoris at the top of the file.
Functions (The Lazy Coder)
At a glance
Big idea: Instead of repeating the same arm code over and over, we give it a name and call it as a function.
- Robotics experience needed: Same robot as Week 10.
- Python experience needed: Students create and use their first custom function.
- Main outcomes: Program has a
grab_thing()function that is called from the main code.
Before class (teacher prep)
- No special build changes; use the robot from Week 10.
-
Prepare a simple non-robot example of a function on the board, e.g.,
def morning(): wake_up(), eat(), brush().
Concept story (10β15 mins)
"I am lazy. I don't want to write the code to 'Open the Claw' 50 times. I want to write it once, give it a name, and just call the name. This is a Function."
-
On the board, write a simple function in English first (e.g.,
morning()β wake up, eat, brush). -
Then show the Python version:
async def grab_thing():and explain that everything indented under it belongs to that function.
Phase 1 β Build the function (25β30 mins)
Mission: Create a grab_thing() function that opens and closes the claw.
- Students type the function definition
async def grab_thing():and the arm code inside it. - They do not call it yet; they just make sure it runs if they call it manually.
Phase 2 β Use the function in a mission (25β30 mins)
Mission: Drive to a brick, use grab_thing() to pick it up, and then return.
- Students add calls to
grab_thing()in their main code at the right time. - They run the program and adjust arm degrees as needed.
from hub import port
import motor_pair, motor, runloop
async def grab_thing():
# Close and open the claw
await motor.run_for_degrees(port.E, 90, velocity=300)
await runloop.sleep_ms(500)
await motor.run_for_degrees(port.E, -90, velocity=300)
async def main():
motor_pair.pair(motor_pair.PAIR_1, port.C, port.D)
# Drive forward to the object
await motor_pair.move_for_amount(motor_pair.PAIR_1, 20, motor_pair.UNIT_CM, 0, velocity=360)
# Use the custom function
await grab_thing()
runloop.run(main())
What each part does
- Function definition:
async def grab_thing():teaches Python a new command. - Reuse: Whenever you write
await grab_thing(), Python runs all the steps inside the function. - Organization: Functions make long programs easier to read and change.
If things go wrong
- Function never runs: Check that you have
await grab_thing()insidemain(). - Indentation errors: Ensure the lines inside
grab_thing()are indented one level, and the lines inmain()are indented under it.
Strategy & Logic
At a glance
Big idea: Plan the final competition mission on paper before touching the robot.
- Robotics experience needed: Students know how to drive, use sensors, and move the arm.
- Python experience needed: They use "pseudo-code" (plain English steps) instead of real code today.
- Main outcomes: Teams have a clear written plan for how their robot will complete the mission.
Before class (teacher prep)
-
Set up a simple competition field with:
- Zone A: Base
- Zone B: Sample/brick area
- Zone C: Drop-off zone
- Provide each team with large paper and pencils or markers.
No Robots Today
Today is for paper and pencil. Teams must map out their path for the final competition. Measure distances. Write "Pseudo-code" (fake code) on paper.
Test, Fail, Fix
At a glance
Big idea: Failure is expected. Students learn to debug robots systematically.
- Main outcomes: Students run their planned mission, identify problems, and improve their code or build.
Engineering mindset (10 mins)
"Your robot will fail today. That is good. If it works the first time, you are lucky, not smart. Find the bug. Fix the bug. Try again."
The Class Cup
π The Rules
- 2.5 minutes per run.
- Robot starts in Base.
- Autonomous Only: If you touch it outside of base, penalty!
- Points for: Leaving Base, Following Line, Delivering Brick.
Error Decoder
Click the error message the student is seeing.
Expand your expertise
Recommended deep dives and guides matched to Teacher's Companion: LEGO SPIKE Prime.