Powering up the Microbit and Start CodingSharath
In this topic, we will see how to power up the microbit and start coding. Microbit provides two ways to powering it up either via USB Cable or via a battery pack. The USB cable is a micro-USB and it can also be used to flash the HEX Code. HEX Code is a machine understandable code from the program you created.
Step 1: Open the Microsoft block editor by visiting the URL: https://makecode.microbit.org/. You can also check out the Python editor. For now, we will be using the block editor.
There is a Live Simulator on the Left side and Next to that we have Package toolbar, where you can find all the block elements. Then we have a workspace on the right-hand side (Next to Toolbox). This is where you drag and drop the blocks to code a microbit. At the bottom of the simulator, you can see a download button where you can download the HEX Code and Flash it to the microbit.
Step 2: So let’s try some simple programs to get started. So let’s fire up some LEDs (I mean turning it ON) to show a Heart shaped icon to share your love using the Microbit.
Step 3: There is two block by default there are ‘on start’ and ‘forever’. The on start block runs when microbit is powered ON. Same like a logo appears when you switch ON your mobile phone. The forever event runs continuously. In this program, we don’t need the ‘on start’ event. I’m going to delete ‘on start’ event and keep the ‘forever‘ loop only. To delete it tap the ‘on start’ then press delete on the keyboard or simply drag it back to the toolbox. Now we can start adding the other blocks.
Step 4: Just click on the Basic on toolbox then it will show the related blocks. We will use the ‘show leds’ blocks. It also shows some hint of the block and what it will do when you hover over it.
Step 5: Just drag and drop the ‘show leds’ to the workspace and fix it inside the forever block. Now choose the LEDs to make a heart shape icon. There is also a default block named as ‘show icon‘ with a heart shape. You can use that too. Here I’m showing this to draw the icons, you can also draw smileys, numbers, etc.
The simulator on the left side shows the output of the block code.
Step 6: It will look good if the heart blinks. So let’s add ‘clear screen‘ and ‘delay‘ to it. So open basics and click more to see ‘clear screen’ just drag and drop after the show led block. Next add ‘pause 1000ms‘ similarly.
Step 7: Now we have the code ready. Give any filename and click save. It will download automatically to your desktop. Navigate it and then right click -> Send to -> Microbit. (Make sure you connected the microbit with Desktop via USB Cable). Once copied the folder will automatically closed and the microbit starts executing the code.
Note: Whenever you Flash (Upload) a new code the Old code will automatically be replaced by the new code. This means the old code will be erased from the microbit.
Testing the output:
That’s it. Now the microbit LEDs displays the flashing heart. You can add more delay to reduce the blinking speed.
Download it on your device and try it:
The make code editor with the code we wrote is embedded below. You can click on the ‘Download’ button to directly download the HEX code to your computer and test it on your microbit. If you want to modify the code or try with different codes, you can click the edit icon which is on the top right corner of the embedded editor. This will open the make code website to make changes for you.
Leave a Reply
You must be logged in to post a comment.