To use the SPIKE™ Prime hardware, you must be using an updated/recent version of the Google Chrome Browser.
Sample Code
# Default Program
from spike import PrimeHub, LightMatrix, Motor, MotorPair
from spike.control import wait_for_seconds, wait_until, Timer
hub = PrimeHub()
hub.light_matrix.show_image('HAPPY')
# Test Hub: Happy and Sad
from spike import PrimeHub, LightMatrix, Button, StatusLight, ForceSensor, MotionSensor, Speaker, ColorSensor, App, DistanceSensor, Motor, MotorPair
from spike.control import wait_for_seconds, wait_until, Timer
hub = PrimeHub()
hub.light_matrix.show_image('HAPPY')
wait_for_seconds(1)
hub.light_matrix.show_image('SAD')
wait_for_seconds(1)
hub.light_matrix.show_image('HAPPY')
wait_for_seconds(1)
hub.light_matrix.show_image('SAD')
wait_for_seconds(1)
# Move Motors: Medium Motors on Ports A and B
from spike import PrimeHub, LightMatrix, Button, StatusLight, ForceSensor, MotionSensor, Speaker, ColorSensor, App, DistanceSensor, Motor, MotorPair
from spike.control import wait_for_seconds, wait_until, Timer
hub = PrimeHub()
motorA = Motor('A')
motorB = Motor('B')
motorA.start_at_power(30)
motorB.start_at_power(60)
wait_for_seconds(5)
motorA.stop()
motorB.stop()
Disclaimer
LEGO®, the LEGO® logo, the Brick, MINDSTORMS®, SPIKE™, and the Minifigure are trademarks of ©The LEGO® Group. All other trademarks and copyrights are the property of their respective owners. All rights reserved.
This page isn’t affiliated, authorized, or endorsed by The LEGO Group.