Start by creating a new project. This will be your workspace for building your animation.
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.
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.
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.
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.