warning

Content guidance

Equipment requiring safe usage.

Adult supervision recommended.

video

Lesson video

In progress...

Loading...

Hello, my name's Mrs. Finlay, and today's lesson is titled Pets on the GO! We are going to be doing some coding in a micro:bit and then I'm going to set you a design task using that coding.

Before we start, make sure you're somewhere quiet where you can hear my voice and you can concentrate for the lesson.

In today's lesson, you will need paper and the pencil, you also need access to the micro:bit website.

Now on this, you need to find MakeCode, in actual fact, you can just search micro:bit MakeCode M-A-K-E-C-O-D-E.

And that will take you to the website where you can simulate all the different codes we're going to look at today.

This can be done on a computer or your mobile phone.

Let's look at what we're going to do today.

Well, you should have already done the intro quiz.

We are going to have some little start task where we do some programming, get you warmed up.

We're going to do some coding, where we look at counting and I'm going to set you that design task to do with pet products.

And as always, there will be an exit quiz.

Let's look at today's keywords.

Okay, so our first keyword that we're going to look at, servo motor.

Now we've done things on motors previously, but this is a special type of motor that will stop at set angles.

And if we're trying to get control into our design products it's a great component to use.

Our second keyword is continuous.

Now it seems a bit obvious, but it's a great command to put into our coding to make sure that the command will last forever.

And our third keyword is string.

This is a command that's going to allow us to put lettering across the front of our micro:bit so that we can send messages.

And I'm going to start you on a starter task to do with using that command very soon.

Let's have a look at this question.

So, on the piece of code seven of the LEDs will light up.

Do we think that's true or false? Have a look.

Have a look at the code, have a look at micro:bit.

What do you think? Okay, you ready, I'm going to go for it.

Yeah, it's true.

So our coding on the left is telling the micro:bit to show that specific display, and that's what's being shown.

Let's do one more warm up.

Look at the code, does the micro:bit show the display you would expect? Let's look at the code together.

On start, show number, light level.

Look at the micro:bit, do you think they match? Make a decision.

Okay, let's have a look.

No, now why do you think they don't match? What is it on the micro:bit that doesn't match up to light level? Okay, let's have a look.

Yeah, the code shown.

The code should be temperature.

Okay, it's degrees C, it's temperature that showing not light level.

If you got that, absolutely amazing, well done.

Okay, I'm going to introduce you to a new way of coding now where we're going to use a string.

Now a string is when the LEDs come across the screen and you can type in whatever you want.

So let's have a little look.

I've prepped up a demonstration, let's look together.

So we're going to start with a simple string, we're going to do on start, show string, and we're going to say, Tom, that's the name of our let's say dog, 11 Cherrytree Lane, let's see, have a go.

You can either programme alongside me or you can have a go at doing this yourself or you can watch the video and then do the programming.

So I'm going to press play.

So I'm using the on start from the main screen, I'm clicking on Basic and there's that show string and then it's very simple.

All I'm doing is typing in Tom 11 Cherrytree Lane.

And then I go over to my micro:bit and there we go.

Can you see the letters moving across? Tom one, one 11 comma Cherry tree, bit of a space, lane and it's case sensitive as well.

So you could do this in capitals and it would look better.

So what I'm going to do now is I'm going to get you to pause the video, get MakeCode up, so you've only got to search micro:bit MakeCode and you'll get this screen.

I then want you to have a go at putting your own string titles in.

So you're going into Basic, show string, pop it into the on string, and see if you can get your own LED string going across your micro:bit.

You might want to rewind this video and just watch the demonstration again.

Okay, I've got a little task for you slightly different this time.

I'm not giving you the code, and I'm going to, I've written a string out and it has an animal's name and then it has where they live.

And what I want you to do is I want you to tell me what is the name of the animal and where do they live? So to do this, you are going to need some paper and a pencil 'cause you're going to have to write down each letter or each number as it scrolls across the front of the micro:bit.

So grab your paper and pencil.

Okay, you ready? I'm going to press play on the micro:bit.

So you get to watch micro:bit, every letter or number that comes down.

Okay, so first of all it's going to be the name of the animal, let's go.

That's the animal, let's look at the address, and that is it.

So what did you get? You should have got splash, 145A Oak Avenue, tricky, yeah? Sometimes if you code it in capitals, it's a little bit easier to understand but if you got that, amazing.

If you've got splash, that's really good because it came very quickly and you had to get your head around reading the micro:bit.

I'm going to show you how to create the stepping counting code.

So we're going to start with Basic, and we're going to scroll down to the bottom until we find on start.

Now you might already have on start on your screen, that's great, mine just disappeared.

And then I'm going to go to Variables, now this is probably the trickiest bit.

I'm going to make a new variable and this one is going to be called step, right? I'm going to have set step to zero so that means at the very start of our programme the step count is always going to be naught.

I'm then going to put in how I want the micro:bit to know to count one, two, three steps.

So my input is going to be shake.

So on shake, I'm going to go back down to variables and we are change.

So on shake, change the step by one.

And now I want to tell it to display how many steps there are.

So I'm going to go into Basic, show number, but I'm going to change this number to steps 'cause I want it to show me the steps.

So there's that.

Okay, and it's that easy.

That's as easy as it is.

So if I now go over to my micro:bit, I go shake it one.

Oh, it's easier to press shake.

Shake two, three, four, five, six, and so it continues.

Here's our step counter code and I just want you to think about how could we add a reset into it? Let's have a look.

That's right, we could press button A and set it back to zero.

So that's how we add a reset.

What I would like you to do is pause the video now and I'd like you to write this code down 'cause you're going to need it later in the lesson for one of the design challenges.

Okay, I'm going to show you how to use surveys or at least how to bring them into the micro:bit software.

If you really love doing this coding then this will be the start for you and you can go on and play with it.

But I thought it'd be really good just to show you very quickly how we can move our motors.

So the first thing we need to do is go into Advanced all the way down, and go into Extensions and you're going to select Survey and you'll find that that will then appear in your bank of blocks, okay? So there's a survey there.

So I'm just going to have on start, we're going to go into Surveys, I'm going to say set survey, here we go.

Set survey PO angle to 90, and I'll just wait for my micro:bit, there it is, to catch up.

And if I press play, there we go you can see it moving from the corner down to that angle.

If I change the angle to 45, there we go and it moves 45, okay? And if I set that again to 180, it will move back for me.

Okay, so you can play with the angles and you can move that servo motor to the angle that you want it to be.

You might want to pause the video now and have a play.

Well done.

Now, if you didn't quite manage to, can you make sure you've written that code down because I'm about to give you some design challenges and having the code written down is going to help and support you.

So if you haven't got it written down, if you press pause, you can quickly jot that down.

Okay, you ready for today's design challenges? I have three.

What I'm looking for is for you to use some of the programming knowledge we've done today, but also design a product in which your microbits can sit.

Now we know that this unit is called pet tech so don't be surprised when we've got three amazing pets who need your programming help.

Let's look at the first one.

We've got Lewis, the Red Setter and he needs an ID tag.

He lives at flat 2b Wellington Avenue.

You need to work out how to code your micro:bit to display this information.

Can you remember the coding we did at the start of the lesson? What will you be using, what was it called? When the lettering goes across the micro:bit, can you remember? Yeah, it's really good, it's called a string and that was one of our keywords today, wasn't it? So to answer this one, you need to programme a string with his name, Lewis, flat 2b Wellington Avenue or you might want to shorten it, up to you.

Let's look at the next challenge.

Count those steps.

Dahlia, the Friesian cow, obviously, is undergoing physiotherapy for a twisted hoof, poor Dahlia.

Okay, the vet needs to ensure that she walks at least 500 steps a day.

Write a code which counts steps and has a display, which can see 500 steps.

Now, what coding did we use today that we could use in this design problem? Can you remember? Yeah, that's right, using the shake to count, didn't we? So that's why it was important that you wrote that down.

So to solve the problem, to help the Friesian cow, you need to write a code so that every time she walks, that step is counted and that it also displays on the micro:bit.

As always, I would like you also to design, and you can model this at home if you wanted to, something to go onto the cow so you could see how many steps that she had done.

And if you're really good, maybe you want to add an icon at the end when she's hit 500 steps, maybe a glass of milk or something, I don't know.

Okay, so that's the second one, let's look at the third one.

Okay, a quick bite to eat.

I have no idea what this one's about, let's have a look.

Oh, dear, Billy the snake has become rather overweight as a result, he's only allowed food at certain times of the day.

Write a code that would allow a motor to start and stop simulating a food bowl opening and closing.

Now, this is all about our stepper motor that we've just used.

So if we're using our stepper motor on an angle, it might be attached to the top of a bowl and it might open up the bowl and there would be Billy's fruit and snack.

Now this one is very much on the designing.

So if you fancy yourself an engineer, this is the one to choose.

What you getting to attach to the bottom of the survey so that when it moves, it opens up and shaves the bowl.

So this is a great little product designing one as well.

So these are your three tasks.

Animal ID, count those steps, and a quick bite to eat.

Who are you going to help today? Lewis, Dahlia, or Billy the snake? As always, I know your teachers are going to want to see what you have made.

Well done today, I'm sure you've had a great time designing products and putting those codes in them.

And don't forget when you're designing in the future coding is so easy and quick to do, and lots of fun too.

We'll see you very soon, take care.