A DC motor can also be controlled using a relay and a Micro:bit. A relay is an electrically operated switch that can be controlled by a small current from a Micro:bit to switch on or off a larger current that powers the DC motor.
Here are the general steps to control a DC motor with a relay and Micro:bit:
This method is simple, but has a drawback of not having a control over the speed of the motor. The motor will be either on or off, no in-between. The relay is not a good option for controlling the speed of the motor. Also, when working with relays, it is important to be aware of the safety precautions, such as disconnecting the power supply before connecting or disconnecting the relay.
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.
Micro:bit is a small, low-cost microcontroller board that was developed by the Micro:bit Educational Foundation for use in computer education. It is designed to be easy to use and accessible to a wide range of users, including children and beginners. The Micro:bit board measures about 4cm by 5cm and features a 25-pin edge connector, a 5×5 LED matrix, two programmable buttons, an accelerometer, a compass, a Bluetooth Low Energy (BLE) module, and a USB connector.
The Micro:bit is widely used in education, providing a hands-on learning experience for students of all ages to learn computer programming, logic, and problem-solving. It’s also used by hobbyist and makers to create fun and interactive projects.
Microbit GPIO board
A Micro:bit GPIO (General Purpose Input/Output) Expansion Board is an accessory that can be used to extend the capabilities of a Micro:bit by providing additional input/output (I/O) pins. These pins can be used to connect sensors and actuators, such as LEDs, buttons, motors, and other electronic components.
The expansion board typically connects to the Micro:bit using a standard edge connector and provides a set of male headers that can be used to connect external components.
A DC motor is an electric motor that converts direct current (DC) electrical energy into mechanical energy. DC motors are widely used in a variety of applications, such as electric vehicles, robotics, appliances, and tools.
DC motors have several key components:
DC motors can be classified into two main types:
DC motors can be powered by batteries, solar panels or other DC power sources. They can be controlled by using various methods such as using PWM, H-Bridge, relays, and other controllers.
A relay is an electrically operated switch that is used to control an electrical circuit by a smaller current signal, for example, from a microcontroller like a Micro:bit. It allows a low power circuit to switch a higher power circuit, such as turning on a light or a motor with a button press.
A relay consists of an electromagnet, which is activated by a small current flowing through its coil, and a set of contacts. When the electromagnet is energized, it attracts a metal armature that moves to close or open the contacts. The contacts are usually divided into two types: normally open (NO) and normally closed (NC). When the relay is not powered, the normally open contacts are open and the normally closed contacts are closed. When the relay is powered, the contacts change state and either close or open.
There are different types of relays, such as electromechanical relays, solid state relays, and reed relays. Electromechanical relays are the most commonly used type and are characterized by their mechanical movement of the contacts. Solid state relays are similar to electromechanical relays, but instead of mechanical contacts, they use semiconductor devices to switch the current. Reed relays are the smallest type of relays and are used in applications where space is limited.
Relays are widely used in different applications such as automotive, industrial control, home appliances, and robotics. They can be used to switch high voltage or high current circuits, isolation of circuits, and control of motors and other loads.
Connecting wires are used to connect various components in an electronic circuit. They allow for the transfer of electricity, data, or signals between different devices and components.
When connecting wires to an Arduino or other microcontroller, it is important to pay attention to the correct pinout. The pinout refers to the arrangement of pins on the microcontroller and the corresponding function of each pin. The Arduino pinout can be found in the documentation provided by the manufacturer, or in various resources available online.
A test plate, also known as a test jig, is a device used to test electronic circuits and components. It is a board or plate that has been designed to hold and connect various components and devices in a specific configuration, allowing for the easy testing and measurement of their performance.
A test plate can be used to test various types of electronic circuits and components, such as microcontrollers, sensors, and actuators. It typically includes connectors and sockets for connecting wires, power supply and measurement devices such as multimeters, oscilloscopes, and power supplies.
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.