# The Bomb Escape | Boson starter for micro:bit 13

STEP1: Connect the colorful LED strip to pin P0 of the expansion board.

STEP2: Action Recognition

1. Learn the related commands

Firstly, we need the micro: bit board to generate and display a direction randomly, then tilt the board, if the direction the board tilts to is same to the displayed direction, generate a new random direction, if not, micro: bit LEDs panel keeps displaying the current direction. The flow chart is shown as below:

2. Programming

1) Create a variable “target direction” to represent the arrow’s direction on micro: bit LED panel, set the variable value to “pick random 0 to 3”

2）Create a function “generate a random direction”, and make the four numbers “0, 1, 2, 3” correspond to the four directions of the arrow displayed on the LED panel.

3）Make a variable “operation direction” to represent the current direction the board tilts, and use it with “current gesture” to make the four “operation direction” correspond to the four numbers.

4）Here we need to use a “if…then…else”. If the operation direction is same to the target direction, then continue to generate a new random direction.

5）The whole program of this part is shown below:

STEP3: LED Strip Countdown

1. Draw a program flow chart

The LEDs on the LED strip will go off one by one as the time goes by. The faster you react; the more LEDs keep on at last.

2. Programming

1) Create variables “time” and “the number of LEDs”, set “time” to 0, and set “the number of LEDs” to 7(means 7 LEDs keep on). Combine them with “if…then…else” to write the programs as the flow chart.

2） Remember to set the LED’s lighting effect:

3. The whole programs of the last two parts:

STEP4: Score System

1. Draw the flow chart

If the operation direction is same as the target direction, then we get 1 point. If the number of LEDs (keep on) is over 0 when we got 20 points, we are the winner, the final score is the number of LEDs (keep on). Otherwise, we failed.

Here is the flow chart:

2. Programming

1) Create variables “points” and “score”, set them to 0. Combine them with “if…then…else” function to meet the requirements of the flow chart.

2）The final program is shown as below:

License
All Rights
Reserved
0