The Micro:bit is a small, low-cost microcontroller that is designed to be easy to use, even for those with no programming experience. It is commonly used in educational settings and for building simple projects.
The Micro:bit can be used to control a 5V motor, which is a type of electric motor that operates on direct current (DC) voltage. To control a 5V motor with the Micro:bit, you will need to connect the motor to the Micro:bit and use code that you write in a programming environment such as the Micro:bit MakeCode editor to control the motor’s speed and direction.
To connect a 5V motor to the Micro:bit, you will need to use a motor driver or motor control circuit. This is a type of circuit that is used to amplify the small signals from the Micro:bit and provide the necessary current and voltage to drive the motor. There are many different types of motor drivers available, and the specific one you will need will depend on the type of motor you are using and the specific requirements of your application.
Once you have connected the motor and motor driver to the Micro:bit, you can use the Micro:bit’s I/O pins to send signals to the motor driver and control the motor‘s speed and direction. The specific steps for doing this will depend on the motor driver you are using and the code you write.
In this tutorial we will see how to control a DC motor by the Micro:bit card and the DRIVER EXPANSION card while changing the direction of rotation:
If button B on the Micro:bit card is pressed, the motor rotates in the opposite direction.
Microbit card
The BBC micro:bit is a small computing device developed by the BBC for use in computer education in the UK. It is a small, self-contained computer with an ARM Cortex-M0 processor, a 5×5 LED matrix, two buttons, and various sensors and input/output (I/O) devices. It is programmed using a web-based code editor and can be used to create a wide variety of interactive projects, such as games, displays, and sensors. The micro:bit is designed to be easy to use and accessible to beginners, with a focus on hands-on, experiential learning. It is also designed to be highly customizable and can be extended using various add-on boards and hardware.
Micro:bit Driver Expansion Board
The Micro:bit Driver Expansion Board is an accessory for the Micro:bit microcontroller. It is a small circuit board that connects to the Micro:bit and provides additional features and capabilities.
The Micro:bit Driver Expansion Board typically includes a number of connectors and components that allow the Micro:bit to interface with a variety of external devices and sensors. This can include connectors for motors, servos, and other types of actuators, as well as connectors for sensors such as temperature sensors, light sensors, and proximity sensors.
The specific features and capabilities of the Micro:bit Driver Expansion Board will depend on the specific model and manufacturer. Some common features may include:
The Micro:bit Driver Expansion Board is a useful accessory for those who want to expand the capabilities of their Micro:bit and build more complex projects.
DC motor
A 5V DC motor is a type of electric motor that operates on direct current (DC) voltage. It is a small motor that typically runs on 5V of power, although the voltage may vary slightly depending on the specific motor and the load it is driving. These motors are often used in small electronic devices, such as portable fans, toys, and robotic applications. They are generally very reliable, efficient, and simple to control, making them a popular choice for many different types of projects and applications.
connecting wires
Wires are used to transmit electrical signals and power to various components such as motors, sensors, and microcontrollers. It’s important to properly route and secure the wires to prevent tangles and damage. There are several methods for doing this, including using cable ties, clamps, and wire looms. It’s also a good idea to use different colors or labeling to identify the different wires and their functions. When connecting wires in a robot, it’s important to follow proper safety procedures, such as using the correct wire stripper and connectors, and wearing protective equipment such as gloves and safety glasses.
Battery of 9V
A 9V battery is a type of primary (non-rechargeable) battery that supplies 9V of electrical power. It is commonly used in small electronic devices, such as smoke detectors, portable radios, and guitar pedals. It is also used as a backup power source in some devices, such as alarms and security systems.
Connect the Micro:bit card to the DRIVER EXPANSION board
Connect the two motor terminals to the two M3 pins of the DRIVER EXPANSION board
Connect the (+) pin of the DRIVER EXPANSION board to the (+) terminal of the 9V battery
Connect the (-) pin of the DRIVER EXPANSION board to the (-) terminal of the 9V battery
Here is the makecode program that allows the motor to be turned in both directions by the DRIVER EXPANSION board for Microbit.