[Boson for micro:bit] Notification Light 04

0 3550 Easy
projectImage
HARDWARE LIST
1 Boson Starter Kit for micro: bit
projectImage
projectImage
projectImage

STEP1: Connect Push-button module to pin P0 of the expansion board; connect the LED to pin P1.

projectImage

STEP2: Programming

1) Click “micro: bit” module, find “read digital pin P0” block and drag it to script area.

projectImage
projectImage

2) The “=” in the “Operators” module can be used to judge if the push-button is being pressed. If the value of “read digital pin P0” is “1”, the button is pressed, otherwise, it is unpressed. Nest the block “read digital pin P0” into the equation.

projectImage

Figure 2.3.3 “=” Block

projectImage

3) Find “if then…else” block in the “Control” module, and drag it into the “forever” block.

projectImage

Figure 2.3.4 “If then…else” Block

4) Nest the conditions of equation into the “if then…else” block as shown below:

projectImage

Figure 2.3.5 Nest Blocks

5) Find the block “set digital pin P0 output LOW” in the “micro: bit” module. Revise the block into “set digital pin P1 output HIGH” and place it under “if then” block. When the button is pressed, this command will be executed and the LED will be on. Then place “set digital pin P1 output LOW” block under the “…else” block. When the button is released, the LED will be off.

projectImage

Figure 2.3.6 Run the Program

projectImage

STEP1: Replace the push-button module in the last project with switch knob module.

projectImage

STEP2: Programming

1. Connect the switch knob to pin P0. Click “micro: bit” module and select “read analog pin P0” block.

projectImage

Figure 2.3.8 “read analog pin P0” Block

projectImage

2. Drag “read analog pin P0” to the script area.

projectImage

Figure 2.3.9 “read analog pin P0” Block

3. Drag “set analog pin P0 output” block of “micro: bit” module into “forever" block in script area, and change P0 to P1. Nest the “set analog pin P1 output” block with the block “read analog pin P0”.

projectImage
projectImage
projectImage
License
All Rights
Reserved
licensBg
0