STARLEAP / SPIKE PRIME PYTHON / 2026–27
Build 2026.09.22-090630-0400
On this page
Debugging Field Guide
Use this whenever a robot or program does not do what you expected.
Debug Routine
- Say what you expected.
- Say what actually happened.
- Point to the last line you changed.
- Read the first useful error line.
- Check the port labels against the wires.
- Run the smallest piece that should work.
- Make one fix and run again.
Common Bugs
| Symptom | Check First |
|---|---|
| Nothing runs | hub connection, battery, play button |
| Motor does not move | wrong port, loose cable, jammed build |
| Wrong motor moves | port labels are swapped |
| Program stops immediately | missing await or code finished |
| Syntax error | missing colon, capitalization, quotes, parentheses |
| Indentation error | code inside main(), if, for, or while must be indented |
| Sensor never reacts | wrong port or sensor reading never becomes true |
Usual Program Shape
CODE
import runloop
async def main():
pass
runloop.run(main())
Replace pass with your code.
One-Motor Test
Check the cable first, then set test_motor at the top to the port being tested. Test one freely moving motor at a time.
CODE
from hub import port
import runloop
import motor
test_motor = port.A
async def main():
await motor.run_for_degrees(test_motor, 180, 300)
runloop.run(main())
Stop before changing the cable. If the motor is connected elsewhere, change only the test_motor assignment and run again.
Force Sensor Test
CODE
from hub import port
import runloop
import force_sensor
force_port = port.D
async def main():
print(force_sensor.pressed(force_port))
runloop.run(main())
Change the force_port assignment at the top if your sensor is plugged in somewhere else.
Distance Sensor Test
CODE
from hub import port
import runloop
import distance_sensor
distance_port = port.B
async def main():
print(distance_sensor.distance(distance_port))
runloop.run(main())
The distance is in millimeters. -1 means the sensor does not see anything in range.
Print Labels
Add labels before steps so you know where the program is.
CODE
print("step 1: raise arm")
await raise_arm()
print("step 2: shoot")
await shoot()
If the program stops after step 1, look inside the code for step 1.