SPIKE Prime Web-IDE Interface

Connect to SPIKE™ 3:




# Sample Code from hub import light_matrix import runloop async def main(): # write your code here await light_matrix.write("Hi!") runloop.run(main())



Sample Code (here is SPIKE 3 Python Documentation)

# Default Program
from hub import light_matrix
import runloop

async def main():
    # write your code here
    await light_matrix.write("Hi!")

runloop.run(main())

# Test Hub: Happy and Sad
from hub import light_matrix
import runloop

async def happy_sad():

	for i in range(4):
		# Update pixels to show an image on Light Matrix using the show_image function 
	
		# Show a smiling face 
		light_matrix.show_image(light_matrix.IMAGE_HAPPY)
		await runloop.sleep_ms(250)
		# Show a sad face 
		light_matrix.show_image(light_matrix.IMAGE_SAD)
		await runloop.sleep_ms(250)

	display.display_clear()
	
runloop.run(happy_sad())

# Move Motors: Medium Motors on Ports A and B
import motor
import runloop
from hub import port

async def move():
	motor.run(port.A, 250)
	motor.run(port.B, 250)
	await runloop.sleep_ms(1000)
	motor.stop()

runloop.run(move())




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.