Micro:bit - Introduction to variables - Barclays Code Playground

 Key Stage: Key Stage 2  Coding Language: Micro:bit  Resource type: Lesson plan

Resource overview

In a program, data values can be constant or variable. If data values are variable they can be changed by the program and the user, for example, when the user is asked a question like their age. Variables may change during program execution. In this lesson use variables to track the score in the project using inputs on the micro:bit.

  • Key resource information

    • You will need: Laptops or desktop computers, BBC micro:bits (one per computer), https://microbit.org


  • Teaching assessment opportunities

    • Have the children try out each other’s code – did they all use the same blocks? 
    • What was different? 
    • What is the benefit of using variables in your programme, instead of keeping score on paper?
  • Lesson length

    • 45 minutes


  • Pupil objectives

    • "I understand what a variable is and can use them to programme my micro:bit with various outputs”
    • “I understand the operation of a process and its outcome. I can structure related items of information.”
    • “I can compare, describe and show number relationships, using appropriate vocabulary and the symbols for equals, not equal to, less than and greater than.”. 

Extension activities

Activity book

Micro:bit pet

This workbook will help you create our Micro:bit pet using the micro:bit MakeCode editor.  

Activity video

Space battle challenge

Become a space explorer in this challenge, but you'll need to make some repairs to your ship as you go. Can you fix the rocket by solving the coding challenges? 

Building your curriculum

Any questions?

Code Playground is all about offering the support you need. If you have a question, comment or suggestion, please don’t hesitate to get in touch. We’d love to hear from you.