Want to learn how to build your own digital solutions with Python and Micro:bit? (See below description of a Micro:bit.) You’re in luck! In today’s blog post, we’ll be giving you a crash course on how to make cool digital solutions, such as a quiz game, an earthquake detector, and a digital clock face using Python and Micro:bit! All of these activities are great for a Year 6 extension class or a Year 7-9 Digital Technologies class.

Our crash course consists of 4 video tutorials:

  1. Introduction to Python (beginner level)
  2. Introduction to Micro:bit (beginner level)
  3. Micro:bit projects (beginner level)
  4. Micro:bit projects (intermediate level)

You can watch the full video playlist here.

 

Video 1: Introduction to Python

Introduction to Python is where it all begins. This class is 100% beginner-friendly, and by the end of this 1-hour class, you will be able to build your very first digital solution with Python: a digital quiz game, to be precise!

In this video tutorial, we learn about:

  • Computer programming: what is it?
  • Writing our very first program in Python: more specifically, how to write a piece of code that displays the text “Hello World”
  • Simple commands. A command is something that tells the computer program what task to complete
  • Variables: vestiges for storing data; they are invaluable in programming!

After covering the basics, we learn to build our own quiz game. In our video tutorial, we show you how to build a space quiz that tests the player’s knowledge about space.

You can integrate the quiz game project into any unit you like. If you prefer, you can build a quiz game about biology, history, or any other topic of your choice!

We recommend that you participate whilst watching the video tutorial. You will get the most out of this class by building the project yourself.

 

Here’s how you can get started!

  1. First, download Python.
  2. Follow along with our video tutorial!
  3. If you need to reference the Space Quiz code that we wrote at any point, you can:

Watch the Lesson #1 video tutorial here!

 

Video 2: Introduction to Micro:bit

In lesson 2, we learn what a Micro:bit is and what it can do. A Micro:bit is a tiny, programmable computer with a 5×5 LED grid, 2 programmable buttons, and an accelerometer. We can program and control these features, e.g. we can program scrolling text in the LED grid, or images such as a heart, or other emojis.

 

A Micro:bit.

 

We can program a Micro:bit using Micro:bit’s Python editor.

We can program a Micro:bit using the Micro:bit Python editor.

 

Code can be written in the black area, as you can see above. You can also change the name of your project by changing the text in the top-right box (see below).

We can change the name of our project in the top-right text box.

 

We can then choose to either save or download our project.

  • Saving our code means that we download it as a Python file (.py). This file can be opened and run in other development environments, e.g. IDLE.
  • Downloading our code means that we can download our code as a hex file to drag and drop into the Micro:bit folder. (You’ll understand what this means when you try out some of the activities below!)


We can choose to either save or download our program using the circled buttons.

 

Activity 1: Displaying text

Let’s start with a simple activity: displaying text. The code below allows us to forever (i.e “while True”) display the scrolling text “Hello, World!” on the 5×5 LED grid.

while True:

   display.scroll(‘Hello, World!’)

  1. Check to make sure that the code you input is correct.
  2. Download this file.
  3. Connect your Micro:bit to the computer. You should be able to see the Micro:bit folder appear on your computer.
  4. Drag and drop the hex file that you downloaded into the Micro:bit folder.
  5. Once complete, the Micro:bit should begin displaying the scrolling text straight away.

 

Activity 2: Displaying emojis

Now let’s try to display emojis. The code below allows us to display the image of a heart on the 5×5 LED grid, always (i.e. “while True”).

while True:

   display.show(Image.HEART)

Follow the same 5 steps from Activity 1 above.

 

Activity 3: Combining text and emojis

Let’s put Activities 1 and 2 together. What we want to do is to display scrolling text, followed by the image of a heart, which will display for 2 seconds. This cycle of actions will repeat forever (i.e. “while True”).

while True:

   display.scroll(‘Hello, World!’)

   display.show(Image.HEART)

   sleep(2000)

Follow the same 5 steps from Activities 1 & 2.

 

Congratulations, you’ve learned the basics of the Micro:bit!

Watch the Lesson #2 video tutorial here.

 

Video 3: Micro:bit projects (beginner level)

In lesson 3, we learn how to build two beginner-level Micro:bit projects:

  • A digital clock face
  • A magic 8 ball

Watch the Lesson #3 video tutorial here.

 

Video 4: Micro:bit projects (intermediate level)

In lesson 4, we learn to build a digital solution suitable for a unit on natural disasters. We show you how to make an earthquake detector that displays warning messages.

Watch the Lesson #4 video tutorial here.

 

Crash course complete!

Congratulations, you’ve completed our crash course on how to build digital solutions using Python and Micro:bit! We hope you enjoyed our 4-part video tutorial. If you create your own digital solutions using Python and Micro:bit, we would love to hear from you!

 

 

Want more information? Send us your queries:

Contact Us