Lesson video

In progress...


Hello, my name's Ben and welcome to Lesson 5 of this programming unit, all about sensing.

This lesson is called Designing a step counter and not surprisingly in this lesson, you'll design a project which will enable you to make a Micro Bit into a step counter.

You'll need a pen and a piece of paper.

You'll need somewhere quiet, without distractions.

So when you're ready, let's begin.

Here are the objectives for this lesson.

So you're going to design a project that uses inputs and outputs on a controllable device, that controllable device being the Micro Bit.

In doing that, you'll decide what variables to include in your project.

You'll design the algorithm for your project and you'll design the programme flow for your project.

The project you're designing in this lesson is all about counting steps.

Take a walk between two points.

It could be in the room you're in or outside.

Count how many steps it takes to get between those two points.

What devices could you use to record steps instead, so you don't have to count them.

And how could you use a Micro Bit to help you do this? Take a few minutes to reflect on these questions, pause the video and move on when you're ready.

Let's think about the sensors we've looked at so far in this unit.

What sensor could help a Micro Bit count steps? Let's look at the question to help us decide.

So what sensor could be used in a step counter project, do you think it's the compass? So the compass detects direction, the accelerometer, the accelerometer detects movement or the light sensor, and of course the light sensor detects light.

Which sensor do you think it is? And of course it's the accelerometer.

The accelerometer detects movement.

So if we want to detect steps, we need to be able to detect movement in the Micro Bit.

So in your design, you will be using the accelerometer to sense movement.

I'm going to show you an example of a step counter project on the emulator.

As I go through the project, I'm going to talk through what I'm doing, and I want you to think about what might be behind this project, what the design might look like.

So I'm going to start the project.

And the first thing I'm going to do is press on button B, and I get zero displayed and a message saying keep it up.

That's just scrolling across.

Now what I'm going to do is simulate the movement of the Micro Bit by clicking on SHAKE.

So several clicks on SHAKE, and I'm now going to press button B again.

And this time B is giving me a display of 245 and saying great! Okay, I'm just going to go through that one more time, so I'm going to stop the project and restart it.

So clicking on B initially, I get zero and the message keep it up.

And then following several clicks on SHAKE, this time, I've got 145 and again, the message great! You're going to design your own version of this project.

Here are some design questions which you might want to consider.

What inputs will there be in your project? Think about the inputs you saw on the demonstration.

What variable will you need? And when will that variable need to be changed and displayed? And finally, when will a condition be used in your project? Reflect on those questions and note down your ideas on the handout, pause the video and resume when you're ready.

Think about any other features that could be included in your project.

Make a note of them now on your handout.

So your task, which is provided in the design sheet, is to make a motivational step counter, which can capture and display the number of steps you've taken.

It should encourage you to keep going and congratulate you when you're doing well.

And you should recognise that some of those features were shown in the example a couple of slides ago.

It's now time for you to create your design.

The design format should be familiar.

It's the same as the one we've used in the previous lessons.

So you'll need to think about, firstly, how you set up your programme.

What will you need to make sure it starts in the same way each time? How will you show the number of steps you have walked? What will be on the display? How many algorithms will you need and what will those algorithms look like? What will you need to set and change in your programme.

And what will the flow of the programme look like? You have the design template in the worksheet.

So it's now time for you to complete the design template.

Pause the video to complete your task, good luck.

I hope you enjoyed creating your design.

Here's an example of a completed design using exactly the same format that you've just experienced.

So the task is the same as the one provided to you, to make a motivational step counter, which can capture and display the number of steps you've taken.

It should encourage you to keep going and congratulate you when you're doing well.

The variable we'll need for this project is Step.

And on the display of the Micro Bit, you will see text and numbers.

The numbers will be the number of steps and the display will say, keep it up, if steps are less than 30 and you're doing great if steps are more than 30.

Moving on to the algorithm and the programme flow.

So the algorithm is set steps to 0.

If shake is detected change step by 1.

When button B is pressed, if steps is less than 30, say keep it up.

If steps is greater than 30, say you're doing great.

And we also have the programme flow represented on the right-hand side.

So you should be able to look at the programme flow and the algorithm side by side and see lots of similarities between them.

Now it's time for you to review your design.

Have you identified what will be all displayed? Are your algorithms clear and precise? And are there any additional features which you could add? If you need to, look at the example we provided of a complete design and go back to your design and make any changes.

Pause the video to complete your task and resume when you're finished.

To use your Micro Bit as a step counter, you're going to need to use it away from a computer.

So far, every time we've flashed a programme to the Micro Bit, we've left it connected to the device that you've flashed it from, but we can also use the Micro Bit away.

And the way we do this is using a battery pack.

So I have a battery pack in my hand here, which you can see in the corner of the screen.

So this is for two AAA batteries.

Some Micro Bit battery packs are also for AA batteries and they are slightly bigger than the one I've got here.

To connect a battery pack to a Micro Bit, it's just a simple case of plugging the white plug on the end of the battery pack.

So here's the one I've got on mine here, just a small white plug.

And that plugs in as you're looking at the Micro Bit to the top left hand corner.

Have a think now, what are the advantages and disadvantages of using your Micro Bit away from a computer? Pause the video while you reflect on that question.

The advantages of being able to power a Micro Bit from the battery pack are that the device is much more portable.

If it's not connected to the computer via USB lead, it means you can take it much further away from the computer than you could otherwise.

Therefore you can test it away from the computer.

It also means that you can easily integrate the Micro Bit into other projects.

So if you have a project which you think would be improved by a Micro Bit, the fact that it's portable and you can take it away from the computer is a big advantage.

Let's look at some of the disadvantages.

Well, the first one is obviously you need batteries to power it.

The batteries themselves, the battery pack itself is quite large compared to the Micro Bit and quite bulky, particularly if you're using the AA battery pack, which is bigger than the AAA battery pack.

And finally, you need to connect it back to a computer, to flash it a new programme if you make any changes to your programme.

Thank you for taking part in this Oak National computing lesson.

We'd love to see some examples of the plans you've made during this lesson.

If you'd like to, please ask your parents or carer to share your work on Instagram, Facebook, or Twitter, tagging @OakNational at #LearnWithOak.