What is BBC micro: bit?
Micro:bit (also referred to as BBC Micro:Bit, stylized as micro:bit) is an ARM–based embedded system designed by the BBC for use in computer education in the UK.
The board is 4 cm × 5 cm and has an ARM Cortex-M0 processor, accelerometer and magnetometer sensors, Bluetooth and USB connectivity, a display consisting of 25 LEDs, two programmable buttons; and it can be powered by either USB or an external battery pack.The device inputs and outputs are through five ring connectors that are part of the 23-pin edge connector. And, we can do pretty cool stuff with this micro: bit. I am going to show you one of them.
- Micro:bit (1 pcs)
- usb cable (1 pcs)
- Battery AAA 1.5V (2 pcs)
- Battery Box (1 pcs)
So, let’s test our micro: bit before programming it. There are two ways to test your micro: bit.
- via USB cable
You can test your micro: bit just to see if it is working fine or not. To do so, connect your micro: bit to your computer via USB cable and wait for a second. Your micro: bit will display “HELLO” by blinking LEDs. If it does, then it is working fine.
- via Battery Connector
Insert batteries into battery box and connect your micro bit via power pins and then see if it is displaying “HELLO”. If it is then it is working fine.
Go to https://www.microbit.co.uk/app/ and click on “Create code”.
Help – This is used to get some help if you are stuck anywhere in the middle.
And, we can see that there are other buttons to zoom in and zoom out the IDE and save our code there.
Let’s get started and write our Python code and run it on micro: bit. First, you need to delete that default code. You can run this code also but I am going to delete it and write it again with the description so that you can understand it better. So first, delete that code and follow the steps.
I am going to add a micro:bit library by writing the following code.
In the above code, While is the keyword that starts the loop and True is the keyword. Whatever is there under the While, will execute again and again forever.
In the second line of code, display is an object that refers to the LED on the micro:bit. Calling a method in the display will allow us to control the LEDs. scroll() is the method used to display the string on the Micro:bit by scrolling the text across the display. You can display anything just by replacing the string by your string. So, the above code will display CSHARP on the Micro: bit display.
from microbit import *
The above line of code will display HAPPY Face on the micro:bit. There are a lot of different symbols available to use. Refer this link to know more about it.
Now, add one more line of code for the delay.
- from microbit import *
- while True:
- display.scroll(‘Hello, World!’)
That’s all for coding part. This is very easy.
Now, let us run this code on our micro:bit to see the output. You need to click on the Download button there and copy it to MICROBIT drive. Let us see how to do this.
Plug in the Micro:bit device to a computer via USB.