1 of 23

micro:bits & Blocks

CODING CARDS

A dozen cards that need the code completed.

2 of 23

Basic Input/Output:

  • on start
  • on logo pressed
  • on button A pressed
  • on button B pressed
  • on button A+B pressed
  • on shake

Basic Display:

  • show leds
  • show string
  • show icon
  • show number
  • clear screen

Sound:

  • play tone for a beat
  • play melody
  • set volume

Logic and Control Flow:

  • repeat loop
  • pause (ms)
  • if statement (including "then" and "else" implied)
  • on forever (continuous loop)

Variables:

  • variable: name, change value (represented by "count, change count")

Other:

  • pick random

Total Unique Blocks: 20

Breakdown of Blocks Covered

3 of 23

Card

Title

Blocks Used

1

Corner to Corner

-on start -show leds

2

Blast Off

-on logo pressed -show leds -show string

3

Beating Heart

-on start -show icon -repeat loop

4

Repeating Fireworks

-on button A pressed -show leds -repeat loop

5

Silly Face

-on start -on shake -show leds

6

micro:bit to the Rescue

-on button A/B pressed -show icon -pause (ms) -clear screen -play tone for a beat

7

Music Match

-on button A+B pressed -play melody -repeat loop -show icon -clear screen

8

Y.M.C.A

-on logo pressed -play tone for a beat -set volume -show leds -clear screen

9

Shaker Surprise

-on shake -show string -pause (ms) -clear screen -pick random

10

Count by Twos

-on start -on button A pressed -show number -variable: count, change count

11

Press B for a Smile

-on forever -button B is pressed -if statement -show leds -clear screen

12

Scroll My name

-on forever -button A+B is pressed -show string -show leds -if, then, else

4 of 23

CODING CARDS

to print : pages 5 – 10

solutions : pages 11 – 23

5 of 23

FINISH THE CODE 2

Blast Off

Press the logo button to start a countdown (3, 2, 1) and then make a rocket appear on the screen.

Display a box in the upper right-hand corner of the micro:bit screen. Program the box to move diagonally towards the lower left-hand corner of the screen.

FINISH THE CODE 1

Corner to Corner

6 of 23

FINISH THE CODE 3

Beating Heart!

Can you make a heart pulse 10 times?

FINISH THE CODE 4

Repeating Fireworks

Can you display fireworks bursting on your micro:bit four times?

7 of 23

Display eyes, nose, and a mouth at the start of the code. Then program the micro:bit to stick out its tongue when the micro:bit is shaken.

FINISH THE CODE 5

Silly Face

FINISH THE CODE 6

micro:bit to the Rescue

Oh no, You have been struck with laryngitis! Code your micro:bit as a yes/no answering machine! Press a button A to show a checkmark (yes) and button B to show a X (no). Both symbols should appear for 200 ms. Last, a beep signals you're ready for the next question.

8 of 23

Start program with button A+B. Synchronize the flashing of the diamonds to music. Remember the music should end at the exact time the last diamond displays. Clear icon to finish your program.

Finish the Code 7

Music Match

Finish the Code 8

Y.M.C.A

In 1978, the Village People released "Y.M.C.A." This song became the group’s biggest hit with 12 million copies sold worldwide.

  • Can you program the micro:bit so that the tune plays when the logo is pressed?
  • What code can you add to make the tune play at the highest volume?
  • How can you modify the code to clear the screen after the tune has played?

9 of 23

After pressing button A on your micro:bit, you want to count by twos and show the count on the micro:bit.

Hint: You will need to set up a variable to store the number of presses for button A.

Bonus: Count by fives or tens.

FINISH THE CODE 10

Count by Twos

FINISH THE CODE 9

Shaker Surprise

Code your micro:bit to pick a random number from 1 to 9 whenever you give it a shake. The number should appear for two seconds and then disappear.

10 of 23

Can you make the screen display a question mark on your micro:bit until you press Button A+B? Then program your name to scroll across the screen.

FINISH THE CODE 12

Scroll My Name

After pressing button B, can you show a happy face and then clear the screen immediately.

FINISH THE CODE 11

Press B for a Smile

11 of 23

Possible Solutions

12 of 23

Finish the Code Solution 1

Corner to Corner

13 of 23

Finish the Code Solution 2

Blast Off

14 of 23

Finish the Code Solution 3

Beating Heart!

15 of 23

Finish the Code Solution 4

Repeating

Fireworks

16 of 23

Finish the Code Solution 5

Silly Face

17 of 23

Finish the Code Solution 6

micro:bit to the Rescue

18 of 23

Finish the Code Solution 7

Music Match

19 of 23

Finish the Code

Solution 8

Y.M.C.A. Music

20 of 23

Finish the Code Solution 9

Shaker Surprise

21 of 23

Finish the Code Solution 10

Count by Twos

22 of 23

Finish the Code Solution 11

Press B for a Smile

23 of 23

Finish the Code Solution 12

Scroll My Name