BBC Micro Bit
How to make a smartphonecontrolled robot
The BBC Micro Bit project we will share with you this issue is more complex than the previous ones. This time we will explore the use of micro DC motors controlled by the Micro Bit and build a four-wheel cardboard robot controlled by a smartphone.
Parts and components
Together with the Micro Bit board, this time we will use some cheap components that will make our robot more interesting. A couple of geared micro motors by Kitronik (kitronik.co.uk/2587-n20-series- micro-metal-gearmotor-501.html) will be used in direct-traction mode to drive the four-wheel robot.
The Micro Bit is powered by 3.3V, while the motors need about 5V or more power to work efficiently. To make the two power lines available, I
used a DC/DC step-down converter to provide the 3.3V from the 9V battery power supply (amazon.com/eBootLM2596-Converter-3-0-40V-1-5-35V/ dp/B01GJ0SC2C/ref=sr_1_6?ie=UTF8 &qid=1534091102&sr=8-6&keywords =dcdc+converter).
The step-down converter is a small circuit that, if powered by a higher current, can be configured by a trimmer to erogate a stable lower voltage. To control the motors’ motion, we will use a motor controller based on the L298N IC (amazon.com/QunqiController-Module-Stepper-Arduino/dp/ B014KMHSW6/ref=sr_1_1_sspa?ie= UTF8&qid=1534091333&sr=8-1-spons &keywords=l298+h+bridge&psc=1).
The L298N motor controller is assembled on a small printed circuit board (PCB) ready for wiring and
immediate use. The same motor control board can be used to drive a stepper motor or two DC motors. The circuit is powered by 5V AA batteries in a 6V AA battery holder. The chassis of the four-wheel robot only requires some cardboard. The prototype I built is just an example, and you can design your own as you wish.
The two geared micro motors are sufficiently powerful to be connected directly to the axis of two of the four wheels. The motors’ holders and the rotating parts were 3D printed.
Building
After cutting the cardboard parts of the chassis, I assembled them using my inseparable hot glue gun. Wiring the motor components together is quite easy; you only need to solder two wires to every micro motor terminal, while the rest of the cabling can be wired with the help of a small-sized breadboard.
How the motor controller works
The L298N IC is a component that includes half bridges to control two DC motors. Depending on the impulses sent by the Micro Bit, the motors rotate clockwise or counterclockwise.
While a stepper motor needs four wires to control every step corresponding to a specific rotation degree, to drive a DC motor, only two wires are required; a
single L298N motor controller can drive up to two DC motors.
Every DC motor is driven by two logic signals, connected to the Micro Bit general purpose digital input and output (GPIO). Depending on the logic level of the two signals, the motor will stop, rotate clockwise, or rotate counterclockwise.
To work correctly, the half-bridge motor controller needs a circuit including some discrete components (capacitor, diodes, resistors); however, don’t worry about the circuit design, as inexpensive motor controller boards based on this integrated circuit include the complete circuit ready to use.
BBC Micro Bit block programming
I developed the programme in two phases; first, I wrote simple software to drive the motor forwards and backwards along a short path. After this first test, I created something more interesting: I added some programming to control the four-wheel robot with my smartphone.
The Micro Bit is not only an educational board; it has also attracted an incredible number of makers, developers, teachers, and others. Thanks to the wide number of projects that have grown around this powerful microcontroller, I located online a welldocumented free app for smartphones to control the Micro Bit: Kitronik Move App for Mobile Devices (kitronik. co.uk/blog/kitronik-move-app).
Good documentation on how the app exchanges commands with the Micro Bit is available on the Kitronik website, as the same mobile app is used to control the company’s two-wheel Micro Bit robot.
Analysing how the software works, it was not difficult to hack it, adapting the function calls to the four-wheel prototype that I built. After a few hours of work, the new programme worked and the robot started moving — as easy as counting 1, 2, 3 …
A video of the running robot is available on YouTube: youtu.be/EK0s2ptq7w.