STARLEAP / SPIKE PRIME PYTHON / 2026–27
Build 2026.09.22-090630-0400
On this page
Quick Start And Debug Sheet
Keep this sheet near your computer.
Start Every Project
- Turn on the hub.
- Open the SPIKE App.
- Choose SPIKE Prime.
- Open or create the correct Python project.
- Connect the hub.
- Check every wire matches the port in your code.
- Run after each small change.
How To Use Project Code
Do not paste a whole finished program and race ahead. Build the smallest starter code first, run it, then make one change at a time.
After each run, be ready to point to one line and say what that line controls.
Usual Program Shape
Most programs look like this:
import runloop
async def main():
# Replace pass with your code.
pass
runloop.run(main())
Code inside main() is indented 4 spaces.
Common Imports
Hub screen:
from hub import light_matrix
Hub ports:
from hub import port
One motor:
import motor
Two motors:
import motor_pair
Sensors:
import force_sensor
import distance_sensor
import color_sensor
import color
App sounds:
from app import sound
Hub beep:
from hub import sound
Small Code Moves
Write text:
await light_matrix.write("GO")
Show image:
light_matrix.show_image(light_matrix.IMAGE_HAPPY)
Wait:
await runloop.sleep_ms(1000)
Run one motor: define its port after the imports, before your functions.
pointer_motor = port.A
Inside main(), use the name:
await motor.run_for_degrees(pointer_motor, 360, 500)
Pair two motors: define both ports at the top, after the imports. Match the names and letters to your build.
left_motor = port.E
right_motor = port.F
Inside main(), use the names:
motor_pair.pair(motor_pair.PAIR_1, left_motor, right_motor)
Move motor pair:
await motor_pair.move_for_degrees(motor_pair.PAIR_1, 360, 0, velocity=400)
If Something Breaks
Check in this order:
- Is the hub connected?
- Is the wire in the right port?
- Is the import line there?
- Is capitalization exact?
- Is there a colon after
def,if,elif,else,for, orwhile? - Is indented code inside the block?
- Did you use
awaiton a command that takes time? - Can you run just the first small piece?
Teacher Check Sentence
Be ready to say:
"I changed __________, and it made the robot __________."