SPIKE Prime Robotics Camp — Day 2
Name your moves, then string them together
Each day upgrades our robot.
Get your robot through a maze by:
A solved maze is just a list of moves in order.
New today? Welcome!
Quick recap so everyone can drive:
code.pybricks.com, connect to your hub by namerobot.straight(200) drives forwardrobot.turn(90) turns rightBugs are sensor data.
The robot did exactly what the code said.
What did the code actually say?
Draw a path through a grid, start to finish.
Write it as a list: "forward, turn right, forward, forward."
A program runs top to bottom, one step at a time.
Solving a maze = writing the right steps in the right order.
Last time we typed straight() and turn() over and over.
Let's give those moves names.
def forward_one_cell():
robot.straight(250) # one maze cell
def turn_right():
robot.turn(90)
def turn_left():
robot.turn(-90)
def name(): defines a function.
forward_one_cell()
turn_right()
Writing the name with () calls it — the robot runs that move.
String your named moves into a readable sequence.
forward_one_cell()
turn_right()
forward_one_cell()
forward_one_cell()
Reads like instructions — that's the whole point.
The robot did exactly what the sequence said.
How far is one cell in your maze?
forward_one_cell() onceThe cell size is a guess you measure — not a correct answer.
Get up, move, refuel.
Keep food away from the kits and laptops!
Tape a maze, then solve someone else's.
A completed maze is the win.
sequence — top to bottomdef name(): defines a functionname() calls itGyro Precision
Your turns mostly landed —
but tomorrow we'll give the robot an inner compass,
the gyro, so its turns stay accurate.