Programming and note
Connect Crowtail-Switch and Crowtail-Relay to P1 and P8 ports of Crowtail-Base shield for
Micro:bit. Loosen the screws of the relay, connect one end of the jumper to the 3V3 port of the
Base Shield and the other end of the jumper to the COM port of the Relay. Connect the two
wires of the motor to the NO port of the relay and the GND port of the Base Shield.
Note that
the power consumed by the motor is large, you need to connect a 12V power supply to the
Crowtail-Base shield for Micro:bit.
The hardware connections are as follows:
Digital write:
When the switch is detected
to open, we use the
digital write
module
to turn on the relay (1), and then the battery
box power can flow through the DC motor
so that the battery box and the DC motor
could form a closed circuit, then DC motor
starts to work. When the switch is detected
to be closed (0), the relay will close, then the
closed circuit will be blocked, so the DC motor will no longer work.
Download the program to micro:bit to see what happens.
When the switch is pressed for the first time, the relay will open and the DC
motor will start working. When the switch is pressed a second time, the relay
will close and the DC motor will stop working.
Result
What role do relay plays in automatic control systems? What are the appliances that
also use relays in our lives?
26