Welcome to the DFRobot blog
:
www.dfrobot.com/blog-tag-microbit.html
33
/
86
Program
Task 1
:
Control the fan with the button module
Goal: when the button is pressed, the fan starts running; when released, the fan stops.
STEP 1: The button module connects to P0, which means we will need to use the “digital read”
function on P0 to first detect the status of the button.
The fan module connects to P1. Likewise, to control the fan, we will use the “digital write” function
on P1 to switch it between ON an OFF.
The “digital read” and “digital write” function can be found under “Pins.”
STEP 2: The condition operator "=" under
“
Logic
”
is used to detect whether the button is pressed
or not. When the button is pressed, the “digital read “function returns “1”, which meets the