Dance Party

Connect SPIKE™ 3:
Motors on Ports D and F


  


Audio File:


Note: you must ensure all the Start Time timestamps are in increasing order.

Section

Start Time (seconds):

# Import necessary modules and submodules from hub import port, light_matrix import motor, runloop legs_motor = port.D arms_motor = port.F # Define a simple function for moving motors async def move_motors(): motor.run(legs_motor, 500) motor.run(arms_motor, 500) # Define a function to display text on the light matrix async def display_text(text_in): light_matrix.write(text_in) # Call the functions runloop.run(display_text('1'), move_motors())

Section

Start Time (seconds):

# Import necessary modules and submodules from hub import port, light_matrix import motor, runloop legs_motor = port.D arms_motor = port.F # Define a simple function for moving motors async def move_motors(): motor.run(legs_motor, -500) motor.run(arms_motor, -500) # Define a function to display text on the light matrix async def display_text(text_in): light_matrix.write(text_in) # Call the functions runloop.run(display_text('2'), move_motors())

Section

Start Time (seconds):

# Import necessary modules and submodules from hub import port, light_matrix import motor, runloop legs_motor = port.D arms_motor = port.F # Define a simple function for moving motors async def move_motors(): motor.run(legs_motor, 0) motor.run(arms_motor, 250) # Define a function to display text on the light matrix async def display_text(text_in): light_matrix.write(text_in) # Call the functions runloop.run(display_text('3'), move_motors())

Section

Start Time (seconds):

# Import necessary modules and submodules from hub import port, light_matrix import motor, runloop legs_motor = port.D arms_motor = port.F # Define a simple function for moving motors async def move_motors(): motor.run(legs_motor, 500) motor.run(arms_motor, -250) # Define a function to display text on the light matrix async def display_text(text_in): light_matrix.write(text_in) # Call the functions runloop.run(display_text('4'), move_motors())

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.