Set axle position counter

This block will set the rotation counter for the motor axle.

Set axle position counter block as first input accepts Hub port address. Each hub port has a physical letter printed on its body.

Set axle position counter block as a second input accepts axle position angle, 360 is full axle rotation

The coding block is compatible with all hubs.

The coding block is compatible with motors that have a rotation 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 Motorno
Move Hubyes

LEGO® Powered UP App coding example: Reset axle position value

For this example, you will need:

Step 1: Add coding blocks

  • Flow block – Start on condition
  • Motor block – Set axle position counter select hub port A, select turn angle 0
  • Widget block – Button widget, select widget address 1

When you are done with coding blocks, Coding canvas should look like this

Step 2: Add canvas buttons

  • Select Slider, assign address 0 
  • Select Button, assign address 1
  • Select Display, assign address 2

Step 3: 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.

Use the slider: Observe that when the slider is used, the motor turns, and turn angle is shown on the Display widget.

Press the button: Observe that the Display widget value is reset to 0;

Motor was spinning for some time using Slider widget

Motor axle position value was reset

Back to Motor Blocks page


Leave a Reply

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