Test out your code by uploading it to the micro:bit.
The best way to test your code is by uploading it to the micro:bit. The micro:bit is a type of microcontroller. It can only run one program at a time, but you can upload a new program to it as many times as you like. Each time you upload a new program it will replace the old version.
Connect your micro:bit to the USB port on your laptop.
Click the 'Download' button. This will download your code as a Hex file.
A Hex file is the most common type of file used to program microcontrollers like the micro:bit. It’s not designed to be read by humans – it just looks like a bunch of characters and numbers. It's a type of machine code that the microcontroller can understand.
Changing your program into a Hex file is known in computer programming as 'compiling your code'.
Open Windows Explorer and find the Hex file (it’s probably in your 'Downloads' folder).
Drag and drop it onto the micro:bit in the sidebar. The LED on the back of the micro:bit will flash to let you know the code is uploading. Once it stops flashing, the code will start to run.
Congratulations! You’ve just uploaded your first code to the micro:bit. If it doesn’t work the way you expect, try recompiling your code. Just download it again and drag it onto the micro:bit.