Skip to content

Yr 6 1.2.3 Variables & Data.

Welcome to Year 6 Computing — Micro:bit Lesson 3: Variables & Data! 🧮🚶‍♂️

If you play a video game, how does the computer remember your score? It uses a Variable! Today, we are going to learn how to store and change data by programming our micro:bits to act as a pedometer (a step counter).

Target Standards:

  • CSTA 1B-AP-09: Create programs that use variables to store and modify data.
  • ISTE 1.5.c: Break problems into component parts and develop descriptive models.
  • UK NC: Use variables in programs; design, write and debug programs that accomplish specific goals.

Step 1: Keyboard Warm-up ⌨️ (10 Mins)

Step 2: What is a Variable? 🎬 (5 Mins)

Imagine a variable as a digital box with a label on it. You can put information inside the box (like a number or a word), and you can look inside the box or change what is in it at any time. We call it a variable because the information inside can vary (change)!

Step 3: Micro:bit Classroom – Step-by-Step 🛠️ (15 Mins)

Let’s program our step counter! Log into your teacher’s Micro:bit Classroom.

  1. Go to the red Variables menu and click Make a Variable. Name it steps and click OK.
  2. Drag the set steps to 0 block into the blue on start loop. (This ensures our pedometer starts at zero when it turns on!).
  3. Go to the pink Input menu and drag an on shake block onto your workspace.
  4. Go back to the red Variables menu and drag the change steps by 1 block inside the shake block.
  5. Finally, to see our score, go to the Basic menu and drag show number inside the shake block (underneath the change block). Replace the “0” with your red steps variable!

Step 4: The Reset Challenge 🧩 (20 Mins)

Mission: Build a Reset Button!

Your step counter works beautifully, but what happens when you want to start a new walk? If you don’t reset it, it will just keep counting forever! Can you figure out how to program a reset button yourself?

  • Rule 1 (The Trigger): You must use the Button A+B event. (Hint: Get an ‘A’ button block and use the dropdown arrow to change it).
  • Rule 2 (The Data): When A+B is pressed, your steps variable must go back to zero.
  • Rule 3 (The Screen): After the variable resets, the screen must clear so it is totally blank again.
  • Bonus: Download your `.hex` file to your real micro:bit. Attach the battery pack, put it in your pocket, and test it by walking around the room!

Step 5: End of Lesson Reflection 👋 (10 Mins)

Fill in the reflection tool below to prove your understanding of Variables. Click download to save your certificate!

Variables Reflection

Comments are closed, but trackbacks and pingbacks are open.