For this tutorial, we'll use Microsoft MakeCode for micro:bit. MakeCode allows for some very interactive projects with just a few connected code blocks.

Go to makecode.microbit.org to get started. If you'd like to start learning Makecode, check the first project under Tutorials.

For this project, we'll use two pieces of code: one for the transmitting (remote controller) micro:bit. And another MakeCode program for the receiving micro:bit which will include blocks for using Crickit.

Transmitter MakeCode

The radio controls are in the Radio block group (pink). On the start of the program, we set the radio group to 1. If multiple micro:bits are in a room, you can keep them from interfering by setting unique radio groups. We do need to keep this number the same as our receiver micro:bit on the next page.

The rest of the code is in two Input blocks: on button A pressed and on button B pressed. When button A is pressed, the code within the on button A pressed block is run, the same for B.

The actions for both are very similar: Display the letter of the button pushed with show string, send a unique command (0 for A, 1 for B) via radio send number, pause a bit so you can see the letter on the display and clear the display by show string with a blank character.

If you want to send more commands, I would suggest grabbing the on shake block. This allows you to control things via 11 different gestures (click shake and the editor will show you the range of options). The on button block also accepts on button A+B.

Load the Code

In this area of the editor, select a unique name for your code, I used transmitter.

If you click the download button it is similar, the editor will ask you to save the file on your computer storage.

The instructions that pop up are what we follow to download the code.

Be sure the micro:bit you want to program is plugged in via a good USB data+power cable. The editor saves the code in a file named microbit-projectname.hex. Our project name is Transmitter. Go to your file explorer / finder on your computer. With the micro:bit plugged in via USB, you should see a new flash drive pop up named MICROBIT.

Navigate to the directory where you saved your .hex file. Using the mouse, drag the .hex file over to the MICROBIT drive. The micro:bit should program itself and start running your code. Press the A and B buttons and you should see the letter A or B on the LED matrix.

This guide was first published on Feb 27, 2019. It was last updated on Feb 27, 2019.

This page (Transmitter Code) was last updated on Jan 25, 2021.