[Boson for micro:bit] Flash the LED Light 03
Project2: Flash the LED Light
STEP1: Connect micro: bit board to micro: bit expansion board.
STEP2: Connect the LED module to pin P1 of the expansion board.
1. Open Mind+ interface, create a new project and select micro: bit board in extensions. Scroll down the “micro: bit” blocks to find “set digital pin P0 output LOW” block, drag it onto script panel. Then we need to change “P0” to “P1”, “LOW” to “HIGH”.
Figure 2.2.4 Set Digital Pin
2. Drag the “forever” block out from “control” module, nest “set digital pin1 output HIGH” block in forever(loop) statement, and place them under the main program. Then “upload” the program to your device.
3. Result: the LED will be on when the code is uploaded successfully.
1) The connection is same as above. Create a new project to make the LED flash.
2) How to flash the LED? Just let the LED repeatedly keep on for 1 second and keep off for 1 second. To achieve that effect, we need to use “wait 1 sec” block in “control” module.
Figure 2.2.7 “wait 1 sec”
3) Place “wait 1 sec” block under the “set digital pin P1 output HIGH” block so as to let the LED keep on for 1 second then do the next action.
Figure 2.2.8 Drag “wait 1 sec” Block
4) Next, we need to let the LED keep off for 1 second. Right-click “set digital pin P1 output HIGH”, then click “Duplicate”.
Figure 2.2.9 “Duplicate” Blocks
5) Place the duplicated blocks under the block “wait 1 sec”, change “HIGH” to “LOW” to let the LED keep off for 1 second. Since we used forever statement here, the program of LED flashing will be running all the time.
Result: the LED keeps flashing when the code is uploaded successfully.