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 name | Compatible |
WeDo 2.0 Medium Motor | no |
Medium Linear Motor | yes |
Technic™ Large Motor | yes |
Technic™ XL Motor | yes |
Technic™ Small Angular Motor | yes |
Medium Angular Motor | yes |
Large Angular Motor | yes |
Train Motor | no |
Move Hub | yes |
LEGO® Powered UP App coding example: Reset axle position value
For this example, you will need:
- Hub – any hub from Hubs compatible with LEGO® Powered UP App list will work
- Motor – any motor that has rotation sensor from Motors compatible with LEGO® Powered UP App list will work
Step 1: Add coding blocks
- Flow block – Start
- Flow block – Repeat instructions infinitely
- Motor block – Run motor select hub port A,
- Widget block – Slider widget, select widget address 0
- Flow block – Start
- Flow block – Repeat instructions infinitely
- Widget block –Display widget, set widget address 2.
- Motor block – Report axle position, select hub port A
- 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
Leave a Reply Cancel reply