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

  1. Turn on the hub.
  2. Open the SPIKE App.
  3. Choose SPIKE Prime.
  4. Open or create the correct Python project.
  5. Connect the hub.
  6. Check every wire matches the port in your code.
  7. 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:

CODE
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:

CODE
from hub import light_matrix

Hub ports:

CODE
from hub import port

One motor:

CODE
import motor

Two motors:

CODE
import motor_pair

Sensors:

CODE
import force_sensor
import distance_sensor
import color_sensor
import color

App sounds:

CODE
from app import sound

Hub beep:

CODE
from hub import sound

Small Code Moves

Write text:

CODE
await light_matrix.write("GO")

Show image:

CODE
light_matrix.show_image(light_matrix.IMAGE_HAPPY)

Wait:

CODE
await runloop.sleep_ms(1000)

Run one motor: define its port after the imports, before your functions.

CODE
pointer_motor = port.A

Inside main(), use the name:

CODE
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.

CODE
left_motor = port.E
right_motor = port.F

Inside main(), use the names:

CODE
motor_pair.pair(motor_pair.PAIR_1, left_motor, right_motor)

Move motor pair:

CODE
await motor_pair.move_for_degrees(motor_pair.PAIR_1, 360, 0, velocity=400)

If Something Breaks

Check in this order:

  1. Is the hub connected?
  2. Is the wire in the right port?
  3. Is the import line there?
  4. Is capitalization exact?
  5. Is there a colon after def, if, elif, else, for, or while?
  6. Is indented code inside the block?
  7. Did you use await on a command that takes time?
  8. Can you run just the first small piece?

Teacher Check Sentence

Be ready to say:

"I changed __________, and it made the robot __________."