Introduction to the micro:bit: parts of the device and the MakeCode environment
This tutorial offers lessons for learning programming with the micro:bit through exercises in programming languages such as Scratch and Python, later extended to JavaScript. The goal is to make learning interesting for beginners, giving them the chance to see the results of their programs right away on the micro:bit. Inspired by a handbook from the British Council, this programme is designed as an interactive alternative to classic console applications, helping users develop basic programming skills through practical, visually supported examples.
The micro:bit can send data from its sensors to the serial port, so that the data is used later in another application or process. To see how this data is used in Processing applications, see the page: Processing and the micro:bit
The micro:bit device
The micro:bit is a hand-held programmable micro computer. It consists of a board, a processor, sensors, LEDs, a serial input-output port and buttons. It can be connected to Processing, which is suitable for creating visual applications. It is well suited for teaching children programming.
By connecting the micro:bit and Processing you can create interesting applications, because Processing's already rich library for creating animations and physics simulations can be enriched with measurements of temperature, acceleration, light level, distance to objects etc. using the micro:bit.
It can be programmed in the programming languages Scratch, JavaScript or Python. Here are some recommendations:
- For programming in Scratch-style blocks or JavaScript use Microsoft's MakeCode: https://makecode.microbit.org/
- For programming in Python install the Mu editor: https://codewith.mu/en/download
- In the following pictures you can see the front and the back of the micro:bit
You can find more details about uses of the micro:bit in the article: Uses of the micro:bit in various areas (SR)

Parts of the micro:bit
The parts of the micro:bit:
- The front board
- The back board
- A screen with 25 LEDs
- Buttons A and B are on the left and right side of the screen; the micro:bit registers when a button is pressed. There is also a reset button for restarting the program, that is, loading it again
- Compass – finds the direction (the points of the compass) and can measure the strength of a magnetic field
- Accelerometer – detects the movements of the micro:bit
- Temperature sensor – this sensor measures the temperature of the micro:bit's processor.
- Pins – along the edge of the micro:bit there are 25 contacts, 5 large and 20 small. Various additional devices and sensors can be connected through these pins.
The labels of the 5 large pins: 0, 1, 2, 3V, GND. The first three are general purpose, 3V provides a power supply of 3.3 V, and GND is the ground.
- Bluetooth – this antenna on the micro:bit is used for wireless connection with other devices: other Bluetooth devices, a computer, a mobile phone or some other device.
In the next picture you can see the parts on the front of the micro:bit

In the next picture you can see a detailed view of the back of the micro:bit.

A description of the parts of the micro:bit
- LED matrix (5x5): used for showing messages and symbols.
- Buttons (A and B): let the user give input.
- Movement sensor (acceleration sensor – accelerometer): detects tilt and movement. The accelerometer is a component that registers movements, that is, changes in speed and position; it is also possible to measure the speed of movement indirectly. With this component you can register when the micro:bit is moved. It is also possible to detect other activities, for example shaking, tilting or free fall.
- Compass: follows the orientation in space. It is the part of the micro:bit that detects the Earth's magnetic field, which lets us find the direction the micro:bit is facing. Before use, the compass has to be calibrated.
- Bluetooth: for wireless communication with other devices.
- Connectors: connecting to external sensors.
- Pins (P0, P1, P2, 3V, GND): let you connect additional sensors and actuators. P0, P1 and P2 are analogue-digital, while 3V and GND provide power.
- Processor: the central chip that controls all the components and runs the instructions of the code. It also contains a temperature sensor that can measure the temperature of the surroundings
- Yellow LED: shows the activity of the micro:bit and signals that it is working.
- Reset button: restarts the micro:bit, which helps when testing code.
- Socket (connector): used for power from a battery or a USB cable.
- Bluetooth chip: makes wireless communication and control through apps on mobile devices possible.
micro:bit workshops
micro:bit workshops are part of the creative programming course organised by the Regional Centre for Talents "Mihajlo Pupin" in Pančevo:
Creative programming
Watch several basic workshops using the micro:bit in the following video (in Serbian)
The MakeCode environment
For creating applications with the micro:bit it is best to use the MakeCode platform, which is especially good for beginners and lets you program the micro:bit with blocks, in Python and in JavaScript. It also has many tutorials and examples of programming the micro:bit. On the home page (picture 5) we can start a new project by clicking the New Project button.

From the MakeCode home page you can create a new project by clicking the "New" button, or open an existing one as shown in the picture. There are also many examples in the tutorials offered. When you click New Project, type the name of the project in the dialog, and when you click "Finish" the environment changes as in picture 6:

In picture 6 you can see:
- The menu bar
- The simulator
- The command palette
- The editor, that is, the work area for programming
In the menu you can choose the language you will program in:
- Blocks
- Python
- JavaScript (hidden in the drop-down list)

When the program is written, you need to connect the micro:bit then, or before that (see picture 7), to a serial port and pair it with the computer by clicking the "..." button, then the "Connect device" button, then "Next", then the pair button, and then choosing one of the offered ports from the list (the list shows the connected micro:bit devices), see picture 8, and then clicking the "Connect" button.
To transfer the code to the micro:bit, the micro:bit must be paired, and then you click the "Download" button, see picture 8. After that the latest version of the program is transferred to the micro:bit. An alternative is to first save the code to a file with the extension ".hex" and then copy this file to the root directory of the micro:bit with File Explorer.

Exercise 1: LEDs
On the front of the micro:bit there are 25 LEDs (Light Emitting Diodes) arranged in 5 rows and 5 columns (5x5), which give red light.
In this exercise you need to show one of the predefined pictures on the LEDs, e.g. a smiley or a heart, as shown in the picture:

The same program in JavaScript (MakeCode):
// the "show icon" block inside the "on start" block
basic.showIcon(IconNames.Heart)
The Basic palette
In the picture we can see the groups into which all the commands are sorted: Basic, Input, Music, Led, Radio, Loops, Logic, Variables, Math etc. When we open the MakeCode environment and start a new project, two commands are on the board by default: on start and forever. "On start" groups the commands that run only once, and the "forever" block the commands that run in an endless loop. In the Basic palette in the picture below you can see some more commands from that palette:

Commands from the Basic palette:
- show number – shows numeric values
- show icon – shows a certain icon on the LED screen.
- show leds – lets you draw your own picture on the screen with 5x5 LEDs.
- clear screen – clears all the pixels on the screen.
- pause – pauses running the code for a certain time (in milliseconds).
- show string – shows a sequence of characters (text) on the screen, letter by letter.
- forever – makes the blocks inside this command run all the time in a loop.
- on start – runs the program when the micro:bit is switched on
- show arrow – shows arrows on the screen of the micro:bit
Exercise 2: LEDs – a blinking heart
Task: Change exercise 1 so that instead of a heart picture that is shown all the time, it is now shown every second with blinking. The "show icon" command, which in exercise 1 was inside the on start block, will now be moved into an endless loop, that is, the "forever" block, as shown in picture 11. To make the blinking effect, add a pause (the "pause" command) of 1 second in the same block, right after the command that shows the picture.

The same program in JavaScript (MakeCode):
basic.forever(function () {
basic.showIcon(IconNames.Heart) // show a heart
basic.pause(1000) // wait 1 second
basic.clearScreen() // switch off all the LEDs
})
The program in Python (MakeCode):
def on_forever():
basic.show_icon(IconNames.HEART)
basic.pause(1000)
basic.clear_screen()
basic.forever(on_forever)
Extra task. Exercise 3
Task: Show a smiley on the LEDs that winks with one eye.
Test 1
Answer the following questions to check what you have learned in the lesson "Introduction to the micro:bit" (the quiz below is in Serbian)
Check your knowledge
Open the quiz
Introduction to the micro:bit
1. How many LEDs does the micro:bit screen have?
2. In which environment is the micro:bit programmed with blocks?
3. What does the forever block do?
4. How is a program transferred to the micro:bit?
