Whenever you’re developing your projects, debugging with Makecode and micro:bit is often necessary to iron out any problems that may occur.
This guide will teach you the basics of setting up a debugging function that you can use with any project.
Creating a debug function ensures that you can reuse it wherever you might need it, making it the most efficient way of debugging.
The forever block, will send the string “rotation value:” together with the rotation sensor reading to the debug function which will, in turn, send it all to the serial port which is redirected to the USB connection from the on start block. The info will then be available to see on your computer.
You can use the debugger function anywhere within your project to monitor what’s actually happening behind the scenes. To do this, adjust the label and pin to read when calling the function. As an example, below you can see the debugger function being called with Pin 2 value: as the label and Pin 2 as the displayed value.
You can reuse the same function to display more than one value by calling it multiple times as shown below.
From a quick tap to smashing that love button and show how much you enjoyed this project.
Please select an option to see content specific to your location and shop online.