Musical quiz buzzer for BBC micro:bit: Python for beginners

Musical quiz buzzer for BBC micro:bit: Python for beginners

Follow this step by step guide to turn a BBC micro:bit into a musical quiz buzzer: use it in class or at home whenever you feel the urge to work out who’s ready to answer a question first out of two teams / individuals.

This tutorial is designed for beginners with little or no programming experience in python but it’ll cover:

Concepts you'll understand
Concepts covered in this tutorial

Concepts:

  • Loops: repeating code with a while loop
  • Lists: storing more than one piece of data in order
  • Conditional logic: using IF statements to let your code make decisions.

 

 

Skills covered in this tutorial
Skills covered in this tutorial

Skills:

  • How to display text and images on a micro:bit screen
  • How to detect if a button has been pressed on a micro:bit
  • How to play music on a micro:bit with a speaker
Flappy bird Micro:bit python tutorial for beginners

Flappy bird Micro:bit python tutorial for beginners

Follow these simple steps to code your own version of flappy bird on the BBC micro:bit. This tutorial is designed for someone with little or no programming experience who wants to get started writing python code. You don’t need a micro:bit to follow this tutorial, but it’s more fun if you’ve got one.

The BBC micro:bit only has a 5×5 LED screen so the graphics on our version of flappy bird are going to be predictably poor. But that means that it’s not too difficult to write (my version has 82 lines of code including comments and blank lines)

Before we start:

We’re going to write our program in python using the micro:bit simulator on create.withcode.uk.

Flappy Bird on the BBC micro:bit in python
Flappy bird micro:bit python

Why Flappy Bird?

The original Flappy Bird is a really simple idea for a game that’s fun to play. By going through this tutorial you’ll learn how to understand / use the following in python:

  • How to display text on the micro:bit screen
  • How to use variables to keep track of score
  • How to display images on the micro:bit screen
  • How to scroll images on the micro:bit screen
  • How to detect if the user presses a button
  • How to keep part of your code looping

 

Why Python?

Python is a text-based programming language that’s designed to let you write as little code as possible that gets as much done as possible. There are other languages you can code a micro:bit with which are perhaps easier for beginners but once you’ve mastered the basics in python it’s much easier to create whatever you like – there’s no faffing around dragging hundreds of blocks together and using your keyboard to write code ends up being much faster than using your mouse / tapping your screen. The skills you learn in this tutorial will also help you with other python programming projects – not just those for the micro:bit.

Why the micro:bit simulator?

Testing your code on an actual BBC micro:bit is much more fun than running in in a simulator. You can use the BBC micro:bit site or the offline python editor mu to write code and send it to your micro:bit. Sometimes though, a simulator can be really useful:

  • It lets you test the code without having to download the .hex file and wait for it to copy to the device
  • It’s easier to find and fix errors
  • It lets you run the code one line at a time
Making computing accessible for all (6/6): Compassionate computing lessons

Making computing accessible for all (6/6): Compassionate computing lessons

This post is the last of six in a series with ideas and resources on how to make computing lessons engaging and demanding for as many students as possible. Click here for the original post.

Compassionate computing
Ideas and resources for compassionate computing lessons

I know. If I read this, I’d be questioning the sanity of the author too. How can computing possibly be described as compassionate? More importantly, why should Computing ever be compassionate? If we define compassion as a warm fuzzy feeling that we experience when we see cute-looking-cats or an uncomfortable guilt we try to ignore when we see bad news on TV then we’ve missed the point. Some of my students have volunteered with a fabulous charity whose founder – who established the charity on seeing a room full of children with learning difficulties left to rot in the dark, in their own filth – defines compassion not just as sympathy or empathy, but as empathy with action. When we see the broken world around us, the big question is not “How do we feel about that” but also “What are we going to do about that”.

Whatever you may think about Microsoft, it’s hard not to be moved by the aims (and achievements) of the Bill and Melinda Gates Foundation, set up by Microsoft’s founder to ‘invest’ his wealth helping to alleviate some of the world’s biggest problems. Whether you think Mark Zuckerburg and other billionare tech philanthropists give away money for tax reasons, for their own benefit or because they’re genuinely ‘good’ people is irrelevant. The fact is that they are able to give. Their skills have enabled them to be successful. Their success has enabled them to accumulate fabulous wealth. Their wealth has enabled them to setup, support or save charities around the world to make a difference on their behalf.

Students are often idealists. They want to change the world around them but feel powerless to make a difference. It can be both liberating and hugely empowering for them to realise that the skills they learn in computing can be put to good use now and in the future, not just to make money but also to support the causes they are passionate about.

Ideas:

  • Invite a representative from a local charity to come and speak to your students about how they use technology and social media to raise funds and raise awareness. Contrast this with the dangers of using social media as part of a lesson on eSafety.

    e.g. “Go to the BBC news web page and see if you can work out how to change one of the headlines to “Cure for cancer found”. Our visitor today works for a charity that is working hard to make that headline a reality. They’re going to explain today how your computing skills can help

  • Discuss and research current events with your students. Take time to get them thinking about how technology can help or hinder any big news item (e.g. refugee crisis / terrorism / poverty / conflict)

    e.g. As part of our web design unit we’re learning how to use HTML tags to make our own web pages. Today I want you to use <h1>, <img> and <p> tags to make a newspaper headline

  • Create a display full of ideas of how students can use the skills from each project / topic / unit of work to make a positive difference to the world around them. Students can help with ideas.

    e.g. “Today is our last lesson on game design. As homework I want you to choose between: A) find a game that promotes or advertises a charity or B) Think of an idea for a game that could promote a charity. e.g. The UNHCR is the United Nations charity in charge of refugees. They could have a game where you have to rescue refugees and catch people traffickers.

Example Activity: Obesity crisis

This activity teaches students how to use 2D lists / arrays in python. Use the above code to plot a map of obesity in different countries. Use the link in the code to find out and add the obesity stats for more countries. Discuss with the class how technology might be to blame for obesity in some countries and how technology can be part of the solution.

Then, get students to write the code for turning a BBC micro:bit into a pedometer that can encourage people to take more exercise: