Skip to main content

27 June 2022

Micro:bit 2-Wheeled Robot

Greg King profile image
Written by

Greg King

Overview

This article is going to sound like I work for Kitronik, but I don't - that's just the only place that happened to have all the bits I wanted at the time.  (Which reduced the faff on the school finance order forms for me)

I've been working on ways of using micro:bits while being both cost-efficient and maximising the learning opportunities.  One of the things I really wanted to get working was a cheap two-wheeled robot.

Kitronik do a really nice-looking kit with tutorials.  I haven't seen or used it, but it's available here for £25.50: link

Required Parts

If you want more freedom in the design, or you already have a bunch of components lying around, it is possible to make one yourself.

I used:
- 1 x egg box for the chassis
- 2 x continuous-rotation servos (NOT the 180 degree ones) - 2 x £3.85 link
- 2 x wheels - 2 x £1.35 link
- 1 x caster (a table-tennis ball could suffice in the right chassis) - £1.10 link
- 1 x solderless breadboard - £2.95 link
  (the smaller, cheaper one would probably do the job though)
- 2 x microbit battery packs (from the school's supply)
- 10 x male-male jumper wires - £1 link
- 4 x male-female jumper wires - £1 link
- 1 x micro-bit edge connector - £4.20 link

I make that £20.65, or less if you order parts for 10 or more.  

You could do it without the edge connector and male-female jumpers if you instead bought pigtail alligator clips - £2.95 link

Building from parts will be more flexible (but probably less reliable) than the Kitronik kit.  Don't forget the Kitronik kit comes with a bunch of tutorials and resources as well.

However, a class set of 15 Kitronik kits would be 15 x £23.50 (lower price for 10 or more) = £352.50
A class set of 15 sets of parts would be less than £310 by my calculations.  That's not a huge saving, so unless you really fancy the flexibility, the Kitronik kit might well be the way to go.

Building it

The micro:bit can provide enough power to (just about) power a single servo, but with two servos the circuitry gets a bit more complicated.

Wiring diagram for battery packs, microbit and servos

Anyway, here's how I built my version:

0 - Calibrate the servos*
1 - Screw wheels onto servos (actually takes quite a bit of force to make the screws bite - a good grip is needed!)
2 - cut gaps in eggbox for servos
3 - push servos into holes and secure them with tape if need be.
4 - Blu-tak caster onto bottom of egg box
5 - Wire up battery packs to breadboard (see photo and wiring diagram)
6 - Program micro:bit
7 - Wire up micro-bit and servos (see wiring diagram)
8 - carefully coil up the mess of wires into the egg box so it can close

* wire up a single servo direct to a micro:bit 3V/GND/pin0 and use a program to set the servo pulse to 1500 microseconds.  On the servo, there is an adjustment screw opposite the turning gear.  With the program running, user a screwdriver to adjust that screw until the servo no longer turns.

Photo showing how to connect jumper leads to battery pack

Photo of battery packs connected to breadboard

Photo of how servos are fitted to egg box

Photo of how caster is fixed to bottom of egg box

Activity with Just the Robot

The robot can be programmed as it is - program it just like you would any other micro:bit, but using the 'servo' category of blocks.  A pulse of 1500 microseconds will stop the servo.  Anything less than that (down to ~1100) will turn it one way, while anything more than that (up to ~1900) will turn it the other way.

It's important to remember that the servos are mounted in opposite directions (forward for one is backward for the other).  Set both servo pulses to 1500 microseconds to stop.  Set both to 1300 to turn one way, set both to 1700 to turn the other way.  Set one to 1300 and the other to 1700 to go forwards/backwards.

You could get students to use trial and error to program a course through an obstacle course in the classroom.  To make it more challenging, you could get them to time how far it moves per second and how long it takes to turn 90 degrees.  Then, they could use dead-reckoning (set speed and direction for a chosen time) to plot the entire course without any practice runs.


Building a Remote Control

Micro:bits can communicate with each other via radio.  You can use this to have a second Micro:bit send messages to the robot to tell it how to move.

Here are example programs:

Screenshot of program for robot

Screenshot of program for remote control

The hex files for these programs are here and here.

Activity with the Remote Control

Give the students programs which only make the robot move forward when they press the A button.  Then get them to design a protocol for using the two micro:bit buttons (perhaps in combination with other inputs) to control the robot.  This can link in with GCSE work on protocols - they would actually be designing their own protocol for communication between the two micro:bits.

 

Discussion

Please login to post a comment

anon15714985
27/06/2022 15:15

Greg,
This is fantastic. Do you have some time for a call? I would like to share some work I am doing at the moment on micro:bit robotics that I think you would be interested in . Can you drop me an email on stuart.ball@bcs.uk
Cheers
Stuart

Simon Humphreys
27/06/2022 15:04

Thanks Greg -will give this a go!

Pete Dring
27/06/2022 14:42

This looks really fun - thanks for sharing.