Cover image
    Activity

    Code a micro:bit to Blink

    Control blinking rhythms by changing pause durations.

    Coding
    Get Started
    8-14+
    40:00
    micro:bit Coding Cards

    Code

    Blink

    00:10

    Use a loop to alternate between turning the RGB LED A on or off. Control the rhythm of the blinking by changing the duration of the pauses.

    basic.forever(function () {
        sb.setRgbLedColor(sb.rgbLed(SBRgbLed.RgbLedA), sb.color(SBColor.White))
        basic.pause(1000)
        sb.setRgbLedColor(sb.rgbLed(SBRgbLed.RgbLedA), sb.color(SBColor.Black))
        basic.pause(1000)
    })

    If using micro:bit for the first time, follow this setup.