Skip main navigation

New offer! Get 30% off one whole year of Unlimited learning. Subscribe for just £249.99 £174.99. New subscribers only. T&Cs apply

Find out more

How to make a computer programme

Here, you're going to learn how to simulate getting data from the real world and displaying it on the micro:bit.
Your First Program Hello World

Here, you’re going to learn how to simulate getting data from the real world and displaying it on the micro:bit, to create a simple computer programme.

Hello World on the BBC micro:bit

Let’s create a programme to display the compass bearing and then the text Hello World and a smiley face on the BBC micro:bit.

The data we’re getting from the real world is the compass bearing. In the real world if you were to move the micro:bit it would show a different compass bearing. The location changed, so the data coming in would change.

MakeCode in blocks

  1. Go to MakeCode’s website for the micro:bit.
  2. Select New Project
  3. Create the following programme in either blocks or JavaScript.
  4. Or View our code here:

Hello WorldHello World
(Click to expand)

MakeCode in JavaScript

  1. Here is the same programme, but written in JavaScript. You could write your program in JavaScript or create it in blocks then click on the JavaScript tab to see this code:

Hello World in JavaScriptHello World in JavaScript
(Click to expand)

Programming in Python

Alternatively here’s the same programme written in Python code:

Hello World in pythonHello World in python
(Click to expand)

You can switch between blocks, JavaScript and Python on the MakeCode website.

If you have a micro:bit, download your code to it and try it out. Move your micro:bit and see if you get different numbers for the compass. Where’s north?!

If you don’t have a micro:bit you can view the code in the simulator on the website. Why not try coding in two different languages to get a feel for them?


How did you get on with the coding? Which language did you try? Did you try two different languages? Was there any language you found easy or difficult?

This article is from the free online

Build a Physical Computing Prototype

Created by
FutureLearn - Learning For Life

Reach your personal and professional goals

Unlock access to hundreds of expert online courses and degrees from top universities and educators to gain accredited qualifications and professional CV-building certificates.

Join over 18 million learners to launch, switch or build upon your career, all at your own pace, across a wide range of topic areas.

Start Learning now