In this tutorial we will control a DC motor by the two buttons A and B of the micro:bit card:
1- When we press button A, the motor turns
2- When we press button B, the motor stops.
As for the assembly, we can connect:
For the relay:
For the motor:
The mounting methods are numerous and here are some examples:
Here is the makecode program that allows you to control a DC motor via the A and B buttons of the Micro:bit board.