Skip main navigation

Collect and display data – our turn

Let's record data and show the different ways it can be displayed on a micro:bit
18.4
In a previous activity, we saw data being taken from the physical world and translated into virtual information using juggling balls. We’re going to do this same now again. We’re going to take something from the physical world, in this case steps, and we’re going to count them on a digital device.
37
I’m going to show you how to do this with the BBC micro:bit. I’ll show you the code, and I’ll show you the results. You’ll be able to code along with me.
44.9
If you don’t have a BBC micro:bit, I’ll show you how to take part using the simulator.
50
So we’re going to record our own information on a micro:bit, and we’re going to use it as a step counter. So like before, we’re going to use the accelerometer. But then, we’re going to add the information together.
60.8
So every time I shake this micro:bit, it’s adding a number of shakes. And when I press A, it shows me that the shakes. When I press B, it resets them back to 0. So you can see we’re back down to 2. That’s a very simple version of that program. Let’s look at a more advanced one because when we get– start to get big numbers like 10, the numbers start to scroll across the screen and it gets a bit slow. So let’s look at a different way of recording the information. So you can see a little dot, so I have to get quite a lot of the shakes. And the dots will grow into kind of like a graph.
100.8
That’s kind of a more visual way of showing the number of steps. Again, we can reset them using B. We can show the actual number using A. You’ll notice when I reset using B, it doesn’t reset the screen, so it’s kind of a bug that I haven’t– and I’ve created it, but not using code, just kind of not understanding the logic of the program. So let’s have a look at the more– the final code. So this one uses the same graph. When I press B to reset, it actually clears the screen, so it goes back to 0. So if I just shake it a few times and press A, it’s 2.
143.7
When I press– and then, it clears the screen, which I quite like that. And again, B will clear the screen. So this program, it uses a selection statement. If we get to 100 steps, show a heart. But I’ve changed this to be 10 so that we can do it, just to show you the demonstrations. That’s using selection, checking on the physical data that we’ve gathered, and displaying something different on the screen. In the next step, I’ll go through this code fully with you. I’ll show you how to create all these blocks and what they all mean. So don’t worry about this right now. I just want to show you the simulator so if you don’t have
185.5
your own micro:bit, you can still see what it would do if you did have one. So here we have the simulator. To shake it, you click this circle here and that counts as a step. Then, I’ve coded the buttons. So if you want to click the buttons, we’ve got button A and button B here. So you can see what they would do in real life if you did have
206.5
a micro:bit, so you can still take part in this activity.
This article is from the free online

Build a Physical Computing Prototype

Created by
FutureLearn - Learning For Life

Our purpose is to transform access to education.

We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.

We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.

Learn more about how FutureLearn is transforming access to education