The Shed

BBC Micro Bit

How to make a smartphone­controlled robot

- By Enrico Miglino Photograph­s: Enrico Miglino

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 interestin­g. 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 efficientl­y. 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/eBootLM259­6-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/QunqiContr­oller-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 sufficient­ly 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 inseparabl­e 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 counterclo­ckwise.

While a stepper motor needs four wires to control every step correspond­ing 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 counterclo­ckwise.

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 inexpensiv­e motor controller boards based on this integrated circuit include the complete circuit ready to use.

BBC Micro Bit block programmin­g

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 interestin­g: I added some programmin­g to control the four-wheel robot with my smartphone.

The Micro Bit is not only an educationa­l 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 microcontr­oller, I located online a welldocume­nted free app for smartphone­s to control the Micro Bit: Kitronik Move App for Mobile Devices (kitronik. co.uk/blog/kitronik-move-app).

Good documentat­ion 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.

 ??  ??
 ??  ??
 ??  ?? Rendering of the 3D models, created with Fusion 3D, used to 3D print the wheels and supports
Rendering of the 3D models, created with Fusion 3D, used to 3D print the wheels and supports
 ??  ?? 3D-rendered image of the free-wheel group assembled
3D-rendered image of the free-wheel group assembled
 ??  ?? Left: The wheel parts 3D printed, ready for assembly
Left: The wheel parts 3D printed, ready for assembly
 ??  ?? Below: The drive wheels glued to the geared micro motors and a bench rotation test
Below: The drive wheels glued to the geared micro motors and a bench rotation test
 ??  ?? Below: The free wheels are fixed in place by gluing the axles to the support block, then fixing these to the cardboard
Below: The free wheels are fixed in place by gluing the axles to the support block, then fixing these to the cardboard
 ??  ?? Above: 3D printing the wheels and the other components for the robot
Above: 3D printing the wheels and the other components for the robot
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ??
 ??  ?? Left and right: Preparatio­n of the driving wheels, with the micro motors glued inside their supports
Left and right: Preparatio­n of the driving wheels, with the micro motors glued inside their supports
 ??  ?? Right and below: Constructi­ng the cardboard chassis and fixing the front free wheels in place
Right and below: Constructi­ng the cardboard chassis and fixing the front free wheels in place
 ??  ?? Left: The assembled free wheels and their support glued to the cardboard chassis. With the four-wheel robot design, two free wheels are on the front of the vehicle
Left: The assembled free wheels and their support glued to the cardboard chassis. With the four-wheel robot design, two free wheels are on the front of the vehicle
 ??  ??
 ??  ??
 ??  ??
 ??  ?? Above: The cardboard chassis with the four wheels in place. The driving wheels (with motors) are glued to the rear side of the robot
Above: The cardboard chassis with the four wheels in place. The driving wheels (with motors) are glued to the rear side of the robot
 ??  ??
 ??  ?? Right: Hot-gluing the Micro Bit support in front of the vehicle Below: The finished four-wheel cardboard robot
Right: Hot-gluing the Micro Bit support in front of the vehicle Below: The finished four-wheel cardboard robot
 ??  ??

Newspapers in English

Newspapers from Australia