you need to connect a 12V power supply to the Crowtail-Base shield for Micro:bit
. The hardware
connection are as follows:
On button pressed:
This block is to detect whether the key on the infrared remote control is
pressed and which key is pressed. As soon as the key is pressed, this block detects and runs the
code we want to run when the button is pressed. When the “+” key is pressed, turn the relay
on; when the “-” key is pressed, turn the relay off.
Download the program to micro:bit and see what happens.
Programming and note
When you press “+” key, the fan will be turned on; when you press “-” key, the
fan will be turned off.
Result
The fan can now only be turned on or off, but the wind speed cannot be adjusted. Can
we make a fan that can turn on and off and regulate the wind speed?
45