Introduction
A DC motor is a simple two-lead, electrically controlled device that converts direct current electrical energy into mechanical energy. It comes with a rotary shaft on which wheels, gears, and propellers, etc can be mounted on.
In this guide, learn to connect a DC motor to a micro:bit with a relay module and build a mini fan, then program it in MakeCode.
Complete this guide to learn how to use a DC motor with the micro:bit.
Tools
-
-
-
-
-
-
-
-
-
-
-
-
-
pins.digitalWritePin(DigitalPin.P1, 0) pins.setPull(DigitalPin.P0, PinPullMode.PullUp) basic.forever(function () { if (pins.digitalReadPin(DigitalPin.P0) == 0) { pins.digitalWritePin(DigitalPin.P1, 1) } else { pins.digitalWritePin(DigitalPin.P1, 0) } })
-