Gyro Drive on Spike Prime�using Python
Introduction
2025 Python Gyro Drive – �Starting Homework
https://spike.legoeducation.com/essential/help/lls-help-python#lls-help-python
2025 Gyro Drive
What is Python?
MicroPython
Gotta Have New Features
Coding Show Off vs. Readable
yaw = (motion_sensor.tilt_angles()[0]/10) * -1 # kids may say “Ok I’m done, I cannot understand this.”
robot_angles = motion_sensor.tilt_angles() # get all tilt angles, returns a tuple!! Google: Tuple
yaw = robot_angles[0] # pull out [0] (first one), yaw is decidegrees. Example: -907
yaw = yaw/10 # convert to degrees float (decimal) -90.7
yaw *= -1 # flip sign to match Spike Prime Blocks, left -, right + 90.7
Program Layout
Program Layout - Default
from hub import light_matrix
import runloop
async def main():
# write your code here
await light_matrix.write("Hi!")
runloop.run(main())
Program Layout - Several Sections
Imports |
Globals |
Enum Classes Definition |
Main function Gyro Drive Setup Run Tests Execute Your Code |
Define Your Code |
gyro_drive_settings class gyro_drive methods |
gyro_drive_test class definition |
spinny class definition |
main() call |
Program Layout - Imports
Program Layout – �Spike Knowledge Base
Program Layout : �Global and Enum
Program Layout : �Enums Deep Dive
Program Layout : �Enums Deep Dive
Program Layout : �main function definition
Program Layout :�main function definition
Program Layout : �Creating the spinny classes
Program Layout : �gyro_drive_tests class
Program Layout : �Your functions are called
Program Layout : �Your mission functions
Program Layout : �Your function definitions
Bonus Idea!!!!: �Run Program by Color
Bonus Idea!!!!: �Run Program by Color
See the problem?
Gyro Drive on Spike Prime�using Python
Good luck and have fun!!!