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



Micro Python Basic Course 2: Display built-in image

Posted by SuFiona on

Learning goals:

This lesson learns to display image on a micro:bit dot matrix by Python programming. For example: heart.

Code:

from microbit import *

display.show(Image.HEART)

Below is a list of built-in images:

• Image.HEART

• Image.HEART_SMALL

• Image.HAPPY

• Image.SMILE

• Image.SAD

• Image.CONFUSED

• Image.ANGRY

• Image.ASLEEP

• Image.SURPRISED

• Image.SILLY

• Image.FABULOUS

• Image.MEH

• Image.YES

• Image.NO

•Image.CLOCK12, Image.CLOCK11, Image.CLOCK10, Image.CLOCK9, Image.CLOCK8, Image.CLOCK7, Image.CLOCK6, Image.CLOCK5, Image.CLOCK4, Image.CLOCK3, Image.CLOCK2,Image.CLOCK1

•Image.ARROW_N, Image.ARROW_NE, Image.ARROW_E, Image.ARROW_SE, Image.ARROW_S, Image.ARROW_SW, Image.ARROW_W, Image.ARROW_NW

• Image.TRIANGLE

• Image.TRIANGLE_LEFT

• Image.CHESSBOARD

• Image.DIAMOND

• Image.DIAMOND_SMALL

• Image.SQUARE

• Image.SQUARE_SMALL

• Image.RABBIT

• Image.COW

• Image.MUSIC_CROTCHET

• Image.MUSIC_QUAVER

• Image.MUSIC_QUAVERS

• Image.PITCHFORK

• Image.XMAS

• Image.PACMAN

• Image.TARGET

• Image.TSHIRT

• Image.ROLLERSKATE

• Image.DUCK

• Image.HOUSE

• Image.TORTOISE

• Image.BUTTERFLY

• Image.STICKFIGURE

• Image.GHOST

• Image.SWORD

• Image.GIRAFFE

• Image.SKULL

• Image.UMBRELLA

• Image.SNAKE

Image.ALL_CLOCKS
Image.ALL_ARROWS 

Programming and downloading

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

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

image.png 

Figure 2-1

2.As shown in Figure 2-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.

image.png

Figure 2-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 2-3.

image.png Figure 2-3

4.After the download is successful, you can see that a heart on the micro:bit dot matrix .as shown in Figure 2-4.

image.png 

Figure 2-4.

The code of the experiment:  2.Display built-in image.zip

Micro Python Basic Course

0 comments

Leave a comment

Please note, comments must be approved before they are published