Loading...
Hi, everyone.
My name is Mrs. Jenkins.
I can't wait to learn with you today.
Welcome to today's lesson, which is called Designing a Step Counter, taken from the unit Sensing Movement with physical computing.
By the end of today's lesson, you will be able to design a project that uses inputs and outputs on a controllable device.
In today's lesson, we have four keywords.
These keywords will appear throughout the lesson, so it's really important that we know what they mean before we get started.
Those four words are algorithm, variable, input, and output.
An algorithm is a precise set of ordered steps, which can be followed by a human or a computer to do a task.
A variable is a named piece of data stored in a computer's memory, which can be accessed and changed by a computer programme.
Input is data that is sent to a programme to be processed.
And output is the result of data processed by the computer.
Okay, so those four words, again: algorithm, variable, input and output.
Keep an eye out for them throughout the lesson.
In today's lesson, Designing a step counter, we have got two learning cycles.
The first is Identify inputs, outputs, and variables needed.
The second is Design your algorithm and programme flow.
Let's start with Identify inputs, outputs, and variables needed.
Jacob asks, "How many steps would it take to walk across the room?
" And Jun says, "I think it would take me 10 steps.
" How could they measure the steps without counting themselves?
These devices can help to track steps.
They all have accelerometers in them, as does the micro:bit.
So we have a fitness tracker, a smartphone, and a smart watch.
All of those can track steps.
A step counter has inputs and outputs.
The input is the data received, for example, movement or a button press.
The output is what the device shows or does, for example, a number or a message.
Jacob asks, "What is a variable?
" Great question, Jacob.
A named value that can be changed while the programme runs.
So for example, the variable could be steps.
Every shake adds one step A button press shows the total number of steps.
Okay, let's have a little check.
True or false: A variable is something that always stays the same in a programme?
What do you think?
Have a go.
How did you get on?
I asked you, true or false: A variable is something that always stays the same in a programme?
The answer is false, and the reason why, it changes while the programme runs.
Great job, everyone.
The micro:bit senses shakes, it's an accelerometer.
It can show messages, numbers or images with the LED output.
So you can see on the picture of the micro:bit there where the accelerometer is.
Watch the video of the step counter programme.
Okay.
We have watched the video of the step counter programme.
What did the micro:bit do?
When it was shaken, it added a step.
If button B was pressed, it showed the steps.
And if the steps were above a certain amount, a message was shown.
And there were two messages there.
So one said, "Keep it up!
" and one said, "Great!
" We are going to make a motivational step counter.
So we are going to capture and display the number of steps taken.
We're going to encourage the user to keep going and we're going to congratulate them when they do well.
Watch the video again and think about these questions: How many inputs are there?
When does the variable change?
When is something shown as an output?
When is a decision or condition made?
Okay, so how many inputs are there?
We can see that they were shaking the micro:bit and that is the first input.
And when button B was pressed, it showed steps.
So button B is also an input.
When does the variable change?
The variable will have changed every time the micro:bit has been shaken.
We can't see it changing, but we know it has changed because when button B is pressed, we can see the change.
And when is something shown?
The output.
When button B is pressed, the output is shown.
So we can see two different messages scrolling through there.
We can see, "Keep it up!
" and we can see.
"Great!
" And we can also see the number of steps.
So when is a decision made?
Well, I can see that the first set of steps was only 27, and at that point, it said, "Keep it up!
" The second time the button was pressed, we had 53 steps.
And then the micro:bit said, "Great!
" So it must be happier when we have done more steps, as it's giving us motivational messages to keep moving.
Which of these is an input in a step counter programme?
A: showing a message?
B: pressing button B?
C: shaking the micro:bit?
Or D: displaying a number?
What do you think?
Have a go.
How did you get on?
I asked which of these is an input in the step counter programme?
A: showing a message?
B: pressing button B?
C: shaking the micro:bit?
Or D: displaying a number?
The answer is B and C.
Both pressing button B and shaking the micro:bit are inputs to the step counter programme.
Great job.
Okay, we are going to move on to Task A now.
I'd like you to complete the design sheet.
What variables do I need?
What inputs will be used?
What will be displayed?
Is it text, numbers, images?
Here is our design sheet.
So we have a spot for the variables, inputs and what will be displayed.
Have a go.
How did you get on?
I asked you to complete the design sheet and think about: What variables do I need?
What inputs will be used?
And what will be displayed?
So text, numbers and images.
And I gave you a design sheet that looked a bit like this.
For my design sheet, I have filled in the variables I will need is step.
The input will be a shake or a button press.
And what will be displayed?
Then it'd display the number of steps and display "Keep it up!
" if steps are less than 30, and display "You're doing great!
" if the steps are more than 30.
Great job, everyone.
We're going to move on to learning cycle two now, Design your algorithm and programme flow.
Jacob asks, "What is an algorithm?
" Good question Jacob.
Clear and precise instructions, which can be followed by a human or computer to complete a task.
Remember, it was one of our keywords.
For example, step one: Start counter at zero.
Two: If the device is shaken, add one.
Three: If button B is pressed, show number.
If steps are greater than 20, show message.
Well, what is programme flow?
Programme flow shows what happens and in what order.
And Jun says, "It is like a map for your programme.
It is often shown as a diagram or arrows between steps.
" Thank you, Jun.
That's really good.
Okay, a little check now.
True or false: The programme flow shows what happens and in what order it happens?
What do you think?
Have a go.
How did you get on?
I asked you true or false: The programme flow shows what happens and in what order it happens?
The answer is true.
Great job.
Okay, we have got both our algorithm steps and our programme flow here.
So the algorithm says set steps to zero.
If shake is detected, change step by one.
When button B is pressed, A: if steps is less than 30, say "Keep it up!
" Or B: If steps are greater than 30, say, "You're doing great!
" Okay, and then in our programme flow, we have: Set steps to zero.
On shake, change steps by one.
Button B is pressed, if steps are less than 30, say, "Keep it up!
" If steps are greater than 30, say, "You're doing great!
" A simple step counter will: On shake, add one to steps.
On button B, show steps.
If steps are greater than 30, show "Keep it up!
" So on shake and button B are our inputs.
Our steps are our variable.
If steps are greater than 30 is our condition, and then "Keep it up!
" is our output.
Okay, let's have a little check.
Which of these is a condition?
A: starting the programme?
B: adding one to the variable?
C: If steps are greater than 30, show message?
Or D: shaking the micro:bit?
What do you think?
Have a go.
How did you get on?
I asked which of these is a condition?
A: starting the programme?
B: adding one to the variable?
C: if steps are greater than 30, show message?
Or D: shaking the micro:bit?
The answer is C: if steps are greater than 30, show message is a condition.
Great job, everyone.
When building an algorithm for a step counter, remember to think about: using full instructions, no code yet.
So this is just an algorithm.
We are not building our code today.
Input, process, output.
When and how the variable should change.
And order and selection.
Using a programme flow can help to organise your thinking.
So we can have our programme flow saying, set steps to zero.
On shake, change steps by one.
Button B is pressed, if steps are less than 30, say "Keep it up!
" If steps are greater than 30, say "You're doing great!
" We are going to move on to Task B now.
And I would like you to complete your design ideas.
For the first part, you're going to write out your algorithm on the design sheet.
And for the second you're going to create your programme flow diagram.
Think about: Does your flow follow your algorithm?
Can you trace what happens step by step?
And here we have our design table.
Have a go.
How did you get on?
I asked you to complete your design ideas: To write out your algorithm on the design sheet.
Create your programme flow diagram.
And to think about: Does your flow follow your algorithm?
Can you trace what happens step by step?
And here was our design table.
Here is my algorithm and programme flow.
Algorithm says: Set steps to zero.
If shake is detected, change step by one.
When button B is pressed, if steps is less than 30, say "Keep it up!
" If steps greater than 30, say "You're doing great!
" And the programme flow is set steps to zero.
On shake, change steps by one.
Button B is pressed, if steps are less than 30, say "Keep it up!
" If steps are more than 30, say "You're doing great!
" Well done, everyone.
You've worked really hard today.
Let's summarise our learning.
When making a programme, it is important to think about what variables you are going to use.
A variable is a named value that can be changed while the programme runs.
Creating algorithms as part of a programme design can help simplify the thinking.
Using programme flow is part of the design process that can help visualise how a programme is going to work.
Great job, everyone.
I hope to learn with you again soon.