Wheel IDE

Online demo »

Led lights

Powered Up Led lights example

This example shows how to use the Powered Up led lights.

The led lights can be controlled with the motor commands, motorOn turns the light on, motorStop turns the light off.

Code

#project "Powered Up Leds light example"

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

proc main()
    ; Select the Powered Up device in the IDE...
    selectDevice(DEVICE_POWERED_UP)

    ; Select the Hub device:
    poweredUpSetDevice(LAYER_1, POWERED_UP_HUB)

    ; Select the Hub device:
    motorLayerSetType(LAYER_1, OUTPUT_A, POWERED_UP_DEVICE_LED_LIGHTS)

    motorSetSpeed(OUTPUT_A, 100)

    repeat
        ; You can turn the light on with the motor command:
        motorOn(OUTPUT_A)
        sleep(500)
        ; You can turn the light off with the motor command:
        motorStop(OUTPUT_A)
        sleep(500)
    end
end