Code your own bedroom door sign: python on a BBC micro:bit for beginners

Code your own bedroom door sign: python on a BBC micro:bit for beginners

This is a BBC micro:bit for beginners tutorial that shows you how to write some python code to turn a micro:bit into a sign you can stick to your bedroom door.

Python is a programming language that’s designed to let you write as little code as possible to make as much work as possible. Writing code on in python on a micro:bit is a great way to get your head around the essentials in python and hopefully have a lot of fun along the way too.

The micro:bit has an LED screen with just 5×5 pixels (dots). This isn’t much compared to the 2880×1800 pixels you might be used to if you’ve got a Macbook Pro but it’s big enough to display simple pictures and text one letter at a time.

Try it with code
Display code on a BBC micro:bit

We’re going to be using the create.withcode.uk microbit simulator to write and test our code. To run the code you can press Ctrl + Enter or click on the run button in the bottom right of the code window.

 

If you want to test your code on an actual micro:bit, run the code in the simulator first then click on the Download Hex button. This’ll download a my_code.hex file that will run on your micro:bit when you drag it and drop it as though you were copying a file to USB memory stick.

 

 

There are two ways of displaying text to the micro:bit screen: display.scroll() and display.show(). What’s the difference? Which do you prefer?

Let’s go through each of the lines in turn:

import microbit
microbit.display.scroll("Hello")
microbit.display.show("World")

Line 1 tells python to import the microbit module. That means that python loads some extra code which tells it how to control a microbit. Lines like this, where you’re importing a module, usually go at the top of your code.

import microbit
microbit.display.scroll("Hello")
microbit.display.show("World")

Inside the microbit module there’s another module called display. Inside display is a procedure called scroll. The round brackets after scroll tell python to call (run) that procedure.

 

string
A “string” of characters

Notice the text in the brackets is surrounded by quotation marks: we call this a string because it joins the characters together as though they were threaded on a string like a washing line.

The scroll procedure scrolls the text from right to left, moving it one pixel at a time.

 

 

import microbit
microbit.display.scroll("Hello")
microbit.display.show("World")

Line 3 is similar to line 2 but instead of scrolling the text pixel by pixel, we show one character at at time.

You might notice in some tutorials that instead of  import microbit you see  from microbit import *

Both of these tell python to load code from the microbit module, but the second means that you don’t have to write  microbit. every time you use the microbit module:

from microbit import *
display.scroll("Hello")
display.show("World")
import microbit
microbit.display.scroll("Hello")
microbit.display.show("World")

Both of the two programs above will do the same thing when they run. The top one is easier to write but some people prefer the bottom one to save confusion later in the development process.

What attracts you to computing

Make computing competitive: What attracts you to computing? 4/6

This post is the forth 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.

Competitive computing
Make computing competitive

Everyone loves to win a prize. Even if the prize is really lame. I love getting cheap and tacky Christmas presents because they’re recycled straight into prizes. The weirder the better. Most of the time though, prizes are unnecessary – students just love the respect and recognition of being appreciated, affirmed for winning – whatever that looks like in practice.

Competitions can be quick or last multiple lessons. You can compete on speed of completion, quality of ideas, depth of understanding, quantity of challenges solved, amount of help offered, level of independence / resilience displayed… pretty much anything can be made competitive.

When someone wins, others inevitably lose out so it’s never a good idea to rely too heavily on competitive projects, but an edge of competition in a lesson can do wonders to boost the pace through a dull or tricky topic.

Ideas:

  • Combine collaborative and competitive activities as a way of getting students to support each other whilst also boosting the pace and enjoyment of a lesson.

e.g. “You’re sat in teams for today’s lesson. There are four ways to win points for your team: 1) Be the first to correctly answer a question. 2) Be the first in the class to complete a challenge I set. 3) Be the first whole team to help each other complete a challenge I set. 4) Be the first whole team to be sat silently with screens off when I ask for your attention.

  • Mix up competitions so that sometimes you reward pace, sometimes quantity, sometimes quality, sometimes independence, sometimes assistance towards others and sometimes depth of understanding.

e.g. “Before we start the new topic today we’re going to see who’s the best at touch-typing in the class. You have 5 minutes enter as many races on play.typeracer.com as you can. The student with the highest WPM score and the student with the highest accuracy rating will win today’s …”

  • Liven up revision lessons or end of unit tests with interactive quizes. You can also get students to create these quizes for a homework.

e.g. “You have 20 minutes to revise “Binary / Decimal / Hex conversions”. You can use this self test quiz to help. At the end of your 20 minutes we’ll play a Kahoot to choose our binary champion.

Key questions:

What’s motivating my students to work quickly / carefully / creatively? What incentives are there to go beyond the minimum expectations?

Example Activity: Competitive Programming in Scratch

Competitive Programming in Scratch
Competitive Programming in Scratch

Split your class into teams and get them to compete as a team to solve a range of programming challenges. This link outlines how to do this in a way that promotes independence, resilience and collaboration as well as boosting computational thinking skills.

 

Research and further reading

This paper talks about the dangers of creating an environment which is too competitive in STEM subjects, which can put barriers in the way of some students from learning. Competitive activities shouldn’t only reward those who ‘win’: a good teacher could alternate between rewarding pace, effort, accuracy, attention to detail, creativity and resilience rather than only ever rewarding the highest score.

Despite the dangers of competition mentioned in this paper, other studies (e.g. Porter & Simon, 2013) show competition in classroom activities can be a really healthy way of engaging students and improving outcomes, recruitment and retention.

Tobias, S. They’re not dumb, they’re different: stalking the second tier. Research Corporation, Tucson. 1990
What attracts you to computing

Making computing accessible for all (3/6): collaborative computing lessons

This post is the third 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.

Collaborative Computing

Ideas and resources for collaborative computing lessons

Some people love group work, some people loathe it. Collaboration doesn’t have to mean working in pairs or small groups. Any form of guided interaction between students – online / face to face / written / email – comes with its own challenges but also potential to boost learning and understanding.

The collaboration doesn’t have to be between students either: it’s a great way to involve parents, grand-parents, neighbours or foreign exchange students if you choose your opportunities and platforms for collaboration carefully.

Too much collaboration and a lesson can descend into chaos. A short, focused and well managed collaborative activity though can boost the overall learning and progress well beyond the sum of the individual parts.

Ideas: 

  • Set a homework for students to explain a concept to a relative or neighbour who’s rubbish with technology.

e.g. “Find someone who’s never written a program before and teach them the difference between a string and an integer data type. Get them to write down an example of each”

  • Try silent group work where all communication takes place via email / forum / shared folder / whatever.

e.g. “I’ve emailed you a list of partner: you’ll be working with someone who sits on the other side of the class to you. There’s an attachment with a presentation that needs completing. You need to contact your partner by email, agree who’s working on each slide, share the research and complete the presentation.”

  • Set up a questions & answers forum / shared document and ask students to nominate the person who has been most helpful on it at the end of a lesson where it’s used.

e.g. “While we create our games, I’m not going to help anyone until I can see that you’ve written your question in the Q&A forum. If three people reply to say they don’t know how to help you then I’ll come and help. Otherwise, it’s up to you to explore, discover and support each other. Remember to share links to useful websites and tutorials you find.”

Key questions:

Who is too dependent on me as their teacher? Who is to proud or afraid to ask anyone for help?

Example activity: Tech recommendation project

What tech would you recommend?
Advise-a-gadget project

Split the class into groups. Each group must research and recommend the most suitable piece of technology (e.g. tablet / phone / laptop / desktop) for

  • A successful businesswomen looking to work on the commute from York to London
  • A teenage gamer wanting to play the latest games with the best possible graphics
  • An elderly relative who’s not used the Internet before but wants to keep in touch with relatives and read / watch the news

The group will have to present their recommendations and answer questions from the rest of the class. Each person in the group must say something and have contributed something to whatever you choose to display on the projector screen during the presentation.

 

Research and further reading

This paper recommends a “Trio of best practice” for reducing the number of students who drop out from a computing course (at the University of California). Two of their three recommended strategies involve collaboration between students: peer instruction and pair programming.

Leo Porter and Beth Simon. 2013