BBC micro:bit
Radio Control


Let's be honest. When you think about a robot car, you are wanting to be able to control it remotely. Fun as it is laboriously working out code to direct a robot around a complex route, it does seem easier to be able to respond in real time when things aren't quite what you expect.

With only one GPIO spare on the Bit:Bot and no more analog pins, you'd think that it might be difficult. Fortunately, the radio library for MicroPython is pretty well designed. A second micro:bit can be used as a remote control for the robot car.

Programming - Sending

Here is my code for the remote control. I'm using the accelerometer to go backwards and forwards by tilting the micro:bit and using the two buttons to make the robot turn left and right. Some arrows are used on the LED matrix to help with debugging.

from microbit import *
import radio

chnl = 10

while True:
    y = accelerometer.get_y()
    a = button_a.is_pressed()
    b = button_b.is_pressed()
    if  a and y<-300:
        # forwards left
    elif a and y>300:
        # backwards left
    elif b and y<-300:
        # forwards right
    elif b and y>300:
        # backwards right
    elif y>300:
    elif y<-300:
        # forwards

Depending on the input, or combinations of input, a compass direction is sent to indicate the direction in which to drive the robot. A channel number is used. Radio isn't a direct one-to-one form of communication. If there are other people using the micro:bit radio in your vicinity, the receiving micro:bit is going to pick up and respond to those signals. There are channels numbered from 0 - 100. Our receiving micro:bit will only receive the messages that are sent on the same channel. The default value is 7. Change from that and no one else's radio can interfere with yours.

Programming - Receiving

Here is the script that receives the radio signal and drives the robot in the correct direction.

from microbit import *
import radio

chnl = 10

def Drive(lft,rgt):
    if lft<0:
        lft = 1023 + lft
    if rgt<0:
        rgt = 1023 + rgt

while True:
    s = radio.receive()
    if s is not None:
        if s=="N":
        elif s=="S":
        elif s=="NE":
        elif s=="NW":
        elif s=="SE":
        elif s== "SW":

You might wish to experiment a little with this to get the best performance. My aim was to get a working version. This isn't bad and gave me precise enough control of the robot to drive it around within an area where you'd expect to receive the signal. You can configure the radio to use more power (see the MicroPython documentation) for the radio but I found that default values were more than enough for the distance I'd normally expect. Control was a little jerky on some manouevres but the robot was pretty controllable.


  1. The first challenge is to improve the range of movements and the amount of control you feel over the robot. You could use the accelerometer for more than just backwards and forwards. That would free up the buttons for more functionality. I like to be able control the buzzer for beeping and be able to flash lights when I feel like it. My feline test subjects prefer it that way too.
  2. The example on this page doesn't make full use of the GPIO on the micro:bit that does the sending. You could go for a load of buttons in a much more fancy controller. Use a keypad or an input shift register and you can have full mission control. That would give you the scope to remotely trigger the robot to perform sequences of pre-designed actions.
  3. The radio is a two way thing. The robot can send feedback. The robot could send messages to the controller to confirm the movements that it is doing and they could be displayed on the controller matrix.
  4. With a second micro:bit, you can hookup an LCD screen or use the matrix to display information from the light sensors. With a specially designed course, you could use the line sensors to read information from the track about the position of the robot. Could you work out a protocol and some programs for being able to know where the robot is on the track just from the data it sends you (not looking at the robot)? Think about how you could set up a system of markings that you could recognize with the line sensors. Work out how to make this is compact as possible, taking up as little space as possible on the track/course.
  5. The Neopixels on the robot are pretty cool in themselves. The car makes a nice mood lamp. With a second micro:bit controlling the colour and or the effects on the lights, you can make something interesting withouth even bothering the motors. You could set up a simple line for the robot to follow slowly - something it could follow without having to make too many course corrections. Make it make back and forward using the line to ensure you get to the correct spot. Either that or place find a transparent or translucent container and stick the robot in that with no moving aboout involved. You could use the buttons to trigger different colours and animations of the neopixels. Light show.