Getting started with the BBC micro:bit

8

Stats

1,232 visits, 1,852 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 21 Mar, 2024. Last updated 26 Jun, 2024

The BBC micro:bit is a small single-board computer used widely in education with lots of features like a 5x5 LED screen, buttons, accelerometer (for detecting tilt), thermometer, and more. You can use Construct to communicate with a micro:bit device, and Construct has a built-in BBC micro:bit plugin to make this easy!

As Construct is browser-based software, Construct communicates with the micro:bit directly from a browser using Bluetooth. This means that the browser must support Bluetooth, and the micro:bit must be running a program that starts Bluetooth services. This is all covered in this guide on how to get up and running using the micro:bit with Construct.

System requirements

Construct communicates with the micro:bit using the Web Bluetooth API. This is currently supported in the Google Chrome and Microsoft Edge browsers (and some other browsers based on the Chromium browser engine). Currently, Safari and Firefox do not support the Web Bluetooth API, and so cannot be used with the micro:bit.

Chrome and Edge also only support the Web Bluetooth API on certain platforms. Currently these include Windows 10+, macOS, Chrome OS (Chromebooks), and Android 6+. Other platforms like Linux and iOS are not currently supported, even when using Chrome or Edge.

The system that you are running Construct on must of course also have support for Bluetooth! Most laptops have Bluetooth support built-in. However if you are using a PC which does not have Bluetooth hardware support, you may need to buy a device like a USB Bluetooth adapter. These are cheap and easy to buy online.

Setting up the micro:bit

By default, the BBC micro:bit does not use Bluetooth. In order to make the device available over Bluetooth, it must be running a program that starts Bluetooth services.

Click here to see a sample MakeCode program that starts several Bluetooth services on startup, and displays the current Bluetooth connection status on the LED screen. Click the Edit button to open it in Microsoft MakeCode. Then you can click the Download button to load the program on to the micro:bit, as you would with any other program. For more details on the process of loading a program on to the micro:bit, refer to the help in Microsoft MakeCode, such as Transferring programs to your micro:bit.

Pairing a device

You're now ready to pair a device! Make sure the BBC micro:bit is on and showing the square symbol (indicating not yet connected). Then open Construct and go to the Example Browser, and find and open the BBC micro:bit plugin example. Preview the project, and then click the Request device button.

A popup window should appear with a list of available nearby Bluetooth devices. It will keep scanning and should show the BBC micro:bit device after a moment. If it does not come up, make sure your BBC micro:bit is nearby and that nothing is blocking the signal (such as a wall or object in between it and the other device). When the micro:bit appears in the list, select it and then click Pair.

It may take a moment to connect, but back in the Construct preview window it should report that a device has connected. It may take another moment for the sensors to then start reporting data, and then you should start to see the various readings update, and see a message appear when you press the buttons. Congratulations, you're now using Construct with a BBC micro:bit!

In the example project you can also click the Change LED button to switch to a different screen where you can set the individual LEDs on the micro:bit, or scroll a message across the display.

Next steps

Now you can start designing a custom Construct project using the BBC micro:bit. Note that on every preview you will need to request the device and choose to pair with it again, but this should be quick once the device has been recognized.

As you will see in the example project, the key is to use the BBC micro:bit plugin. This provides triggers such as On accelerometer reading and On button pressed, actions to update the LED display, and more. This provides an easy way to communicate with the device and build a project that does something interesting with it.

There are lots of possible uses with the micro:bit. For example, you can use the BBC micro:bit as a game controller! See the BBC micro:bit controller example project for a demonstration of how to do that. You could do something like make a tiny game that runs on the device's LED screen. It also has a thermometer and magnetometer (for compass bearing).

It's also possible to do raw communication with the BBC micro:bit using Construct's general-purpose Bluetooth object, and the Binary Data object to handle reading and writing data. This allows for more advanced uses, such as making full use of the Bluetooth communication protocol. See the BBC micro:bit raw communication example for a demonstration of that. This document provides the technical specification of the micro:bit's Bluetooth profile.

Some tips

Remember that the magnetometer needs calibration before it can report the compass bearing. If you see "no reading" in the example project, it may be because it is not calibrated. For more details see Calibrating the micro:bit Compass.

It's also worth pointing out that often when using MakeCode, you are designing a program that runs directly on the BBC micro:bit. However with Construct the program that controls the device is running on the PC or laptop you are using Construct on, and it is then controlling the device remotely using Bluetooth.

Finally, remember Bluetooth uses short-range wireless radio communication, which is unreliable. Sometimes readings from the sensors may become intermittent, or the device may lose the connection, depending on the quality of the signal. If you have trouble, try moving the micro:bit closer, or to another location.

Conclusion

Construct's new BBC micro:bit plugin makes it easy to communicate with a micro:bit device directly from Construct. It takes a few steps to get up and running, but once you've got as far as connecting over Bluetooth you are free to start experimenting! If you want to go further, there is also an option for advanced customization using raw communication over Bluetooth. Have fun!

  • 3 Comments

  • Order by
Want to leave a comment? Login or Register an account!