Welcome to Mini Microbit Handle repository
1.Heart beat
1.Heart beat
1. Learning goals
In this lesson, we will learn to use micro:bit to realize dot matrix flashing display of large and small heart patterns.
2.Code and analysis
from microbit import *
This code is to import everything from the microbit library, and any program need to uses import this library.
display.show(image.HEART)
Micro:bit dot matrix display heart pattern.
Sleep(500)
Delay 500ms.
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
Note:
1 - The capital letter/lowercase letters must be distinguished!
2 - Correct spelling!
3 - Keywords such as # need a space between the content.
4 - You can only use the Tab key (tabulation key) for indentation.
3.Programming and downloading
3.1 You should open the Mu software, and enter the code in the edit window, , as shown in Figure .
Note! All English and symbols should be entered in English, and the last line must be a space.
3.2 As shown in Figure, 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.
3.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.
3.4 After the download is successful, you can see that a heart on the micro:bit dot matrix will flashing.