[Boson for micro:bit] Electric Fan 05

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

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

projectImage

STEP2: Programming

1. Click “micro: bit” module, select “read digital pin P0”, and drag it to script section.

projectImage

2. The “=” in the “Operators” module can be used to judge whether the button is pressed. If the value of “read digital pin P0” is “1”, which suggests the button is pressed, otherwise, it is released. Nest the block “read digital pin P0” into the equation.

projectImage

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

projectImage

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

projectImage

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 fan starts to rotate. Otherwise, the fan stops rotating.

projectImage
projectImage
projectImage

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

projectImage

STEP2: Programming

1. Click “micro: bit”, drag “read analog pin P0” block to script section

projectImage

2. Drag the “set analog pin P0 output” of the micro: bit module to the “forever” in the script area, revise P0 to P1, and nest the two blocks as shown below.

projectImage
projectImage
projectImage
projectImage
License
All Rights
Reserved
licensBg
1