Microbit Digital Art
Intermediate
60 mins
Teacher/Student led
+95 XP
What you need:
Chromebook/Laptop/PC
Microbit

Animation

Embark on a journey to create your own animation using a Microbit. Start by setting up a new project, then add an event handler. You'll then create the first and second frames of your animation using 'show leds' blocks. Finally, test your animation by pressing the A button.

Teacher Class Feed

Load previous activity

    1 - Create a New Project

    Start by creating a new project. This will be your workspace for building your animation.

    2 - Add an Event Handler

    Next, you need to add an event handler. This tells your Microbit what to do when a certain event happens - in this case, when the A button is pressed. Add the following code:

    input.onButtonPressed(Button.A, function () {
    
    })

    This code creates a new function that will be called whenever the A button is pressed.

    3 - Create the First Frame of Your Animation

    Now, let's create the first frame of your animation. Inside the function you just created, add the following code:

    input.onButtonPressed(Button.A, function () {
        basic.showLeds(`
            . . . . .
            . # . # .
            . . . . .
            # . . . #
            . # # # .
        `)
    })

    This code uses the 'show leds' block to create a pattern on the LED display. This will be the first frame of your animation.

    4 - Create the Second Frame of Your Animation

    Next, create the second frame of your animation. Add the following code right after the first 'show leds' block:

    input.onButtonPressed(Button.A, function () {
        basic.showLeds(`
            . . . . .
            . # . # .
            . . . . .
            # . . . #
            . # # # .
        `)
        basic.showLeds(`
            . . . . .
            . . # . .
            . . . . .
            . # . # .
            # . . . #
        `)
    })

    This code adds a second 'show leds' block to create another pattern on the LED display. This will be the second frame of your animation.

    5 - Test Your Animation

    Finally, test your animation. Press the A button on the simulator to see your animation in action. If you have a physical Microbit device, this step is optional. You can download the code onto your device and test it there.

    Coding Ireland · Online learning platform

    Unlock the full learning experience

    You're previewing this lesson. Get full access to this lesson and hundreds more — each one ready to teach, with interactive activities, printable resources and pupil progress tracking built in.

    Hundreds of curriculum-aligned lessons
    Interactive activities in every lesson
    Printable resources & progress tracking
    Copyright Notice
    This lesson is copyright of Coding Ireland 2017 - 2025. Unauthorised use, copying or distribution is not allowed.
    🍪 Our website uses cookies to make your browsing experience better. By using our website you agree to our use of cookies. Learn more