DC Motor Micro:bit

Control a DC motor with Micro:bit

Purpose of this tutorial:

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.

Required components

  • micro:bit board
  • Direct current motor
  • GPIO board
  • connection wire
  • relay
  • Test plate


As for the assembly, we can connect:

For the relay:

  • pin S to pin P0 of the Micro:bit board
  • the pin (+) to pin 3.3V of the Micro:bit board
  • the pin (-) to the GND of the Micro:bit board
  • the pin ON to an energy of 5V-9V

For the motor:

  • the first terminal to the COM pin of the relay
  • the second terminal to the GND terminal of the Micro:bit board

The mounting methods are numerous and here are some examples:

Montage (1)

Montage (2)

Makecode program

Here is the makecode program that allows you to control a DC motor via the A and B buttons of the Micro:bit board.

0 commentaire

Leave a comment

Votre adresse e-mail ne sera pas publiée.

Scroll to Top