Skip main navigation

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. https://makecode.microbit.org/
  2. Select New Project
  3. Create the following programme in either blocks or JavaScript.
  4. Or View our code here: https://makecode.microbit.org/_9cvVWz6qLMXK

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?

Progress?

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

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education