[Boson for micro:bit] Flash the LED Light 03

0 4253 Easy

Project2: Flash the LED Light

HARDWARE LIST
1 Boson Starter Kit for micro: bit
projectImage
projectImage

STEP1: Connect micro: bit board to micro: bit expansion board.

projectImage
projectImage

STEP2: Connect the LED module to pin P1 of the expansion board.

projectImage

STEP3: Programming

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”.

projectImage

Figure 2.2.4 Set Digital Pin

projectImage
projectImage

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.

projectImage

3. Result: the LED will be on when the code is uploaded successfully.

projectImage
projectImage

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.

projectImage

Figure 2.2.7 “wait 1 sec”

projectImage

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.

projectImage

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”.

projectImage

Figure 2.2.9 “Duplicate” Blocks

projectImage

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.

projectImage

Result: the LED keeps flashing when the code is uploaded successfully.

projectImage
projectImage
License
All Rights
Reserved
licensBg
0