![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/b12d01b2f1d219405bd1fd739c1537e8.png)
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/dd7302b9b0521e463208f8a9d95605bf.png)
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/e6380cd80e146e5cd3d322ca086bdc98.png)
STEP1: Connect the colorful LED strip to pin P0 of the expansion board.
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/dd49f87cefec1ce37b7987477069a06f.png)
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:
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/13c8a1bfd6ba2325dcc9b2bcbfe61d43.png)
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/cce9e94e11d1fdb363f0983e082b4dc1.png)
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/4d0351375b3fdc86ed6acfc655ba6ed9.png)
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”
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/76cbc8ca821ab54b77dfbcea3a4d556b.png)
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.
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/c69e20f0ec160844ac30b84fefa30333.png)
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.
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/d192ef213035ac4b568e1c72d0e569df.png)
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.
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/0f87afef0de09e0955ddc679ac57454d.png)
5)The whole program of this part is shown below:
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/17474c3bf201df0000832c37e84aec81.png)
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.
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/b1c7addbd1bcbe721b6c5ce4ceb40568.png)
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.
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/6517f3d6f5db072ead27a7c74442b221.png)
2) Remember to set the LED’s lighting effect:
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/6f6aebcfcb303c983aec9ea79a67545d.png)
3. The whole programs of the last two parts:
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/9719934d0f843e5112995c8c2f555048.png)
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:
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/99620f4404c5f709ce04d70996c675a0.png)
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.
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/34145bcf798057ab205ee5591b5395c2.png)
2)The final program is shown as below:
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/7304aa7d7a60342413f35381c32ce3dd.png)
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/a1c227a596455a8ab9ff866abdc8ff46.png)
![projectImage](https://dfimg.dfrobot.com/6188847caa9508d63a4183aa/makelog/589f550b5d10c2044ecac0ff5cba967e.png)
![licensBg](/images/license_bg.png)