Learning area
Robotics with LEGO SPIKE
You program a LEGO SPIKE Prime robot with Pybricks. Every program runs straight away in the simulator in your browser – and later exactly the same on your real robot. The code comes from the book “Python for Robots”.
Chapter 5The hub
- 0525 minutes
Buttons and gyro sensor
Wait for a button press on the hub · Measure the heading with the gyro sensor · Calculate the shortest turn angle with modulo
- 0625 minutes
Display and sounds
Build your own image as a list of lists · Control single pixels and their brightness · Calculate a status display from measurements · Play sounds and melodies
Chapter 6Real hardware
- 0730 minutes
Calibrating
Understand why real robots never drive perfectly · Measure the distance with the distance sensor and the turn with the gyro · Recalculate wheel_diameter and axle_track correctly
- 0830 minutes
Moving to the real SPIKE
Put Pybricks onto the SPIKE hub · Transfer programs from the simulator to the real robot · Measure sensor values before the first run instead of guessing
🏁 Robotics challenges
Five courses in the simulator: who gets the robot into the finish fastest? Share your best time as a link – it's re-checked on the other end.
📘 Book bonus – the 5 big projects
Robot vacuum, PID line follower, alarm system, dance and gripper in the simulator. Unlock them with a question about the book.
Roadmap
Coming next
Real hardware
- Transferring programs to SPIKE