Fun, bite-sized Python programs for learning robotics with LEGO Spike Prime!
These programs teach you how to:
- Control motors and create movement
- Read sensors (color, distance, force)
- Show images and text on the hub
- React to button presses and motion
- Build a line-following robot
- Run multiple tasks simultaneously
- 01_hello_motor_spike3.py - Make a motor spin
- 02_color_sensor_spike3.py - Detect colors
- 03_distance_bot_spike3.py - Stop before hitting walls
- 04_force_sensor_spike3.py - Control motor with force sensor
- 05_motor_pair_spike3.py - Drive a robot with two motors
- 06_hub_display_spike3.py - Show images and text
- 07_button_control_spike3.py - React to button presses
- 08_line_follower_spike3.py - Build a line-following robot
- 09_motion_sensor_spike3.py - Detect tilt, shake, and orientation
- 10_advanced_async_spike3.py - Run multiple tasks at once
Each program lists what you need at the top:
- LEGO Spike Prime Hub (required for all)
- Motors (various ports)
- Sensors (Color, Distance, Force)
- Read HOW_TO_RUN.md for setup instructions
- Start with Lesson 1
- Build the required hardware
- Copy code into LEGO Spike Prime App
- Run and experiment!
✅ Read the comments - They explain each step ✅ Change the numbers - See what happens! ✅ Build first - Make sure hardware is ready ✅ Experiment - Try your own ideas
These programs use the SPIKE 3 Python API which includes:
runloopmodule for async programming- Separate modules for each component (
motor,color_sensor, etc.) - Improved performance and reliability
- Better multi-tasking support
Official SPIKE 3 Python docs: https://tuftsceeo.github.io/SPIKEPythonDocs/SPIKE3.html
After completing these lessons:
- Combine different sensors
- Create your own robot designs
- Build games and challenges
- Explore the full API documentation
Happy coding! 🤖