5% OFF Over $19, Code: Elephant5; 10% OFF Over $59, Code: Elephant10

Microbit Python Tutorials 4: Display custom animation

Posted by SuFiona on

Course 4-Display custom animation

Learning goals:

This lesson learns to display custom animation on a micro:bit dot matrix by Python programming. For example: from smile to sadness and then to anger. 


from microbit import *
while True:
    face1 = Image("00000:09090:00000:90009:09990")
    face2 = Image("00000:09090:00000:99999:00000")
    face3 = Image("00000:09090:00000:09990:90009")
    face4 = Image("90009:99099:00000:09990:90009")
    face5 = Image("00000:00000:00000:00000:00000")
    all_faces = [face1, face2, face3, face4, face5, ]
    display.show(all_faces, delay=200) 

Programming and downloading

1.You should open the Mu software, and enter the code in the edit window, , as shown in Figure 4-1.

Note! All English and symbols should be entered in English, and the last line must be a space.


Figure 4-1

2.As shown in Figure 4-2, you need to click the Check button to check if our code has an error. If a line appears with a cursor or an underscore, the program indicating this line is wrong.


Figure 4-2

3.You need to connect the micro data cable to micro:bit and the computer, then click the Flash button to download the program to micro:bit as shown in Figure 4-3.


Figure 4-3

4. After the download is successful, you can observe the animation of the expression change on the micro:bit dot matrix, as shown in Figure 4-4 to Figure 4-7.

blob.png blob.png

Figure 4-4                                                    Figure 4-5

blob.png blob.png

Figure 4-6                                                   Figure 4-7

The code of the experiment: 4.Display custom animation.rar

Last Microbit Tutorial >> Microbit Python Tutorials 3: Display custom image
Next Microbit Tutorial >> Microbit Python Tutorials 5: See who is pressing fast


Leave a comment

Please note, comments must be approved before they are published