Loading...
Hi, my name is Ben and welcome to this programming unit.
In this lesson, you'll be learning all about the micro:bit.
You'll need access to MakeCode, which is the micro:bit's block-based coding environment.
And if you have a micro:bit itself, you can also use that.
If you don't, don't worry everything we do in this lesson and this unit, we can do in MakeCode itself, and you will learn how in this lesson.
It's handy if you've got a pen and a piece of paper ready for this lesson.
So when you're ready, let's begin.
In this lesson, you're going to create a programme to run on a controllable device.
The controllable device, being the micro:bit.
You're then going to adapt your knowledge of programming to a new environment.
Test your programme on an emulator and finally transfer your programme to a controllable device, to the micro:bit, if you have one.
If not, you can do all of this in MakeCode.
So let's have a look at the micro:bit in a little bit more detail.
The micro:bit is a tiny computer.
You can write programmes for the micro:bit on your computer, and then you can transfer them from your computer to run on the micro:bit itself.
You can see here on the slide, you've got the front and the top and the rear views of the micro:bit and you can see that there's lots of different parts on both the front and the back of the micro:bit.
So let's look at those in a little bit more detail.
So on the front of a micro:bit, have a look at the device, if you have one, or use the image on the screen.
Can you find buttons A and B? And can you find the LED display? An LED is a little tiny light, and on the back can you find the accelerometer and the compass? And can you find the USB port, which connects the micro:bit to a computer So if you'd like to pause the video there and have a look at your worksheets, or have a look at the images on the screen or your device itself and see if you can find those four parts.
So on the front of the micro:bit buttons A and B are circled there and you can see they are labelled.
So button A on the left, button B on the right and the led display is the five by five grid in the middle.
And you can see on our image that some of those LEDs are lit to represent a heart symbol and flipping it over onto the back.
The accelerometer and the compass are combined in a tiny little chip there on the back.
And the USB port to connect to your micro:bit to a computer is up there in the middle of the micro:bit, right at the top for the next part of the lesson, you're going to use the MakeCode environment for the first time.
To find it please go to makecode.
microbit.
org and click on new project.
Take a couple of minutes to have a look around, pause the video.
And then when you're ready, come back to the slideshow.
Does anything in the MakeCode environment look familiar to you? These are the key parts of the screen.
So in the middle, you have your programming blocks.
These are where you choose your blocks, which you code with.
These may look familiar.
If you've used scratch before on the right hand side, we have the programming area.
So the blocks you choose from the code blocks, you place in the programming area.
And again, there's some similarities between this and scratch the blocks look quite similar.
And the programming area, looks similar too.
Where MakeCode is different is on the left hand side, you have the emulator and the emulator is a virtual micro:bit where you can test your code.
So anything you can do on a physical micro:bit, you can test first on the emulator.
This is the part of the lesson.
You've all been waiting for your opportunity to do your first code in MakeCode.
So go to makecode.
microbit.
org and make a new project.
And the challenge for this task is to display some text and an image on the LEDs of the micro:bit, test your code, using the emulator.
To complete this, you will only need to use blocks from the blue basic blocks.
So pause the video here and have a go at that for yourself in MakeCode.
And then I'll show you how you could do that.
Here's how you can display some text and an image on your micro:bit.
So from the basic blocks, I'm going to first use the show string block, which allows us to display text.
And you'll see if I just drag it into the programming area, but don't put it inside either the OnStar or forever blocks, which are there by default, it will show us great ads.
It needs to be inside one of those other blocks or some other kind of events block for it to work.
So I'm going to drag it into the OnStar block there, there we go.
And then also from the basic blocks, I'm going to use a show icon block I'll just drag that over.
And you may notice on the emulator it is already showing the text hello, scrolled across there.
So the show icon block, lets you choose several icons, which you can display on the LEDs without having to click on all the individual squares to make them.
So I'm just going to leave it as the heart shape.
And I'm going to drop that in underneath my string show string hello block, and then on the emulator I'm going to press play allow that to run and you will see it displays hello, and then the heart will appear afterwards.
Your finished code should look something like this.
So I have using an input on button A pressed repeat three times from the loops block show string hello.
And then on button B pressed show icon, heart.
These little menus here are drop downs.
So you can choose button A or button B, or you can choose buttons A and B pressed together.
So let's test to see that, make sure that works on the emulator.
So this time I'm actually going to use the, A button and the B on the emulator.
So if I click on button A, the text hello will scroll across the screen, it's done that once.
And here's the second time.
And it will do that one more time.
And I want to press button B.
We see the heart icon appear.
If you have your own micro:bit, now is your opportunity to transfer your programme from your computer to your micro:bit.
So the graphic on screen shows you that you need a USB cable and your micro:bit.
I have both of those here.
So here's my USB lead and it's a micro USB lead.
So I have the larger end here, which goes into the computer and the smaller end here, which goes into the micro:bit.
So carefully plug in the smaller end into the micro:bit itself.
And it will just click in probably about right it will help.
Click in, there we go.
So that's plugged into the micro:bit and then the larger end goes into a free USB slot on your computer.
Next, you need to click on download within MakeCode.
It's a good idea before you click on download to name your project, something meaningful so that when you need to find it on your computer, you can remember what it's called.
So I've called this one Buttons and Repeat, I'm now going to download that onto my computer.
So what that's done is downloaded it into my download folder.
It's not yet on the micro:bit.
We have one more step we need to complete before we actually put the onto the micro:bit.
And I'll show you that next, the final part of the process of transferring your programme from your computer to your micro:bit is known as flashing.
So flashing is when you take the contents of a file and replace everything on the device, you're flashing it onto.
So my computer has recognised the micro:bit as an external storage device.
And when I take this micro:bit hex file, which is the one I downloaded a minute ago and place that onto the micro:bit, it will replace the entire contents of everything, which is on the micro:bit.
So it's not like an external storage device where you add it to all the other files on that device is it's different when you, when you flash to a device.
So I'm now going to do that.
I'm going to move this file onto my micro:bit, and you'll see the micro:bit is flashing at the back.
So the flashing light indicates that the flashing process is happening.
So that's two different meanings of the same word.
And once it goes back to a solid light, which it will do any second now We know that that programme has flashed to the micro:bit and we can test to see whether that has worked.
So I'm just going to show you the micro:bit the right way up there we are and get button A there.
So you can still see me hopefully, button A should give us hello three times.
So that'll scroll across three times.
Once, twice.
And third time, and I want to press button B there is my heart icon.
So we've successfully managed to flash the programme from the computer onto the micro:bit you'll have noticed, or you may have noticed that I'm using a Mac computer.
So if you're using a PC or a Linux machine, it may look slightly different to this, but the principles are very similar.
You download it from MakeCode.
So MakeCode is stored on the cloud, onto your device.
And then from your device onto the micro:bit.
Here are instructions for the process that you've just seen demonstrated.
So take a minute to follow this instructions and see if you can flash the programme from your computer to your micro:bit.
So the process we followed so far, it's been a really nice example of input process output.
So you have input instructions into the micro:bit, pressing buttons our processes taking place.
And then there has been the output on the LEDs.
So let's recap that, a button is used to input an instruction onto the micro:bit.
A process is carried out on the micro:bit.
The output can be displayed on the LEDs.
In the next lesson, you'll be using the accelerometer on the micro:bit to detect movement.
The accelerometer is an input sensor, many devices you'll be familiar with already have accelerometers within them.
So mobile phones, smart watches, and some games controllers have accelerometers in them.
Take a minute to think about why these devices need to detect movement.
So the mobile phone uses an accelerometer to sense the orientation of the device.
So depending on which way round the phone is being held, the display will adjust.
So you can see the information on it.
Smartwatch uses an accelerometer to detect movement and to record steps.
So it can be used as a step counter or to track exercise and fitness.
And finally, the games controller consent movements, which can then control the actions in games.
Thank you for taking part in this Oak Academy computing lesson.
We'd love you to share your work with Oak National.
If you'd like to please ask your parents or carer to share your work on Instagram, Facebook or Twitter, tagging @OakNational and #learnwithOak.