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.”. 

Related resources

Introduction to Micro:bit

The BBC Micro:bit is an external device designed to introduce children to the basics of coding through physical computing. It's a great way to help your class understand the relationship between code and the devices it controls. Use this lesson to introduce the micro:bit and help your class get started with physical computing.

What is the Micro:bit

Use this handout to show your class the different features of the micro:bit and where they are on the device.

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.