Wheel IDE

Online demo »

Move Hub motor

Powered Up Move Hub motor example

This example shows how to control a motor in the Move Hub. The Move Hub has two built in motors of which the type can't be selected, selecting the Move Hub device automatically sets the two motor types in the simulator.

Code

; Wheel, copyright (c) 2020 - present by Arno van der Vegt
; Distributed under an MIT license: https://arnovandervegt.github.io/wheel/license.txt
#project "Powered Up Move Hub motor example"

; This example shows how to select the Move Hub device in the simulator and
; move the motor to a given angle. The Move Hub has 2 built in motors.

#include "lib/modules/standard.whl"
#include "lib/modules/device.whl"
#include "lib/modules/motor.whl"
#include "lib/modules/poweredUp.whl"

#display "Hub"

proc main()
    ; Select the Powered Up mode in the simulator
    selectDevice(DEVICE_POWERED_UP)

    ; Select the Move Hub device
    poweredUpSetDevice(LAYER_1, POWERED_UP_MOVE_HUB)

    ; Set the motor speed and brake...
    motorLayerSetSpeed(LAYER_1, OUTPUT_A, 100)
    motorLayerSetBrake(LAYER_1, OUTPUT_A, MOTOR_BRAKE)

    ; Reset output A on layer 1
    motorLayerReset(LAYER_1, OUTPUT_A)
    ; Move the motor to 720 degrees
    motorLayerMoveTo(LAYER_1, OUTPUT_A, 720)

    halt()
end