Run the motor for a specified time

This block will run the motor, connected to a specified hub port, at a specified power, for a specified amount of time.

Run the motor for a specified time block as first input accepts Hub port address. Each hub port has a physical letter printed on its body.

Run the motor for a specified time block as a second input accepts motor power value. Values can range from -100 to 100. When the value is a positive number, the motor spins clockwise, when the value is a negative number, the motor spins counterclockwise.

Run the motor for a specified time block as third input accepts time value in seconds

The coding block is compatible with all hubs.

The coding block is compatible with motors that have a speed sensor.

Device nameCompatible
WeDo 2.0 Medium Motorno
Medium Linear Motoryes
Technic™ Large Motoryes
Technic™ XL Motoryes
Technic™ Small Angular Motoryes
Medium Angular Motoryes
Large Angular Motoryes
Train Motoryes
Move Hubyes

LEGO® Powered UP App coding example: Run the motor for a specified time

For this example, you will need:

Step 1: Add coding blocks

  • Flow block – Start  
  • Motor block – Run the motor for a specified time, select hub port A, select power 100, select time 3

Step 2: Setup motor and hub

  • Connect the motor to port A
  • Connect the hub to a device that runs the Powered UP App

Step 3: Run the program. Observe that the motor is spinning at full power, but only for 3 seconds. Observe, that when you start the program and change power value, nothing changes. For changes to apply in this example, you need to restart the program.

Back to Motor Blocks page

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *