Skip to content

DC Motor

DC motors (or just “motors”) can spin when a current is applied. By reversing the current the motor spins in the opposite direction. By changing the voltage the motor spins faster or slower. The Motor Controller board handles the speed and direction control for us.

DC Motor

These come in various shapes and sizes and have 2 wire connections, which might be attached wires or pins on which you can attach the wires.

DC Motor

Wiring

If your motor has bare pins, attach some wires to them:

N20 wiring

Connect the loose wires to the Motor Controller. To do so, unscrew the terminals for the required motor connection (M1, M2, M3 or M4), insert the wires, and then tighten the screws.

Motor controller wiring

Motor controller wiring

Note that if, when running the code, the motor runs the wrong way, you can swap the wires around here to fix the issue.

Coding

To use the motors you need to add the extension.

To add the extension, first click on Extensions:

Extensions block

Then enter the URL for the extension:

Extension

Then click on the extension:

Extension

You should see the following block:

Block

Enter the following code:

Code

Download the code to the microbit.

The motor should move forwards for 2 seconds and then stop.