Lesson video

In progress...

Loading...

Hi, welcome to today's lesson.

My name is Mr. Brown and we are today going to be thinking about how to programme our museum alarms, and also then how to fault find when we're putting everything together.

So we're going to be testing things, making sure it all works, and then thinking about logical ways of finding the faults.

Okay, so that's the introduction.

We're gonna go on and talk about the learning outcomes, the keywords, and the learning cycles.

The learning outcome for today is to programme a micro:bit alarm system and then to test faults in any circuit.

Keywords.

First keyword is millisecond, that's 1000th of a second.

Accelerometer, a device that measures how quickly something is speeding up or slowing down.

Fault finding, testing electrical equipment to check whether it's working safely and correctly.

And logical, thinking in steps using what you already know and coming up with sensible solutions.

Here's the lesson outline.

So for today's lesson we've got two learning cycles.

First one is programme a micro:bit alarm system, and the second one is testing circuits and programmes.

The first learning cycle, we're going to go through a whole variety of different ways of creating a micro:bit alarm system.

So there's different ways of actually doing, solving the same problem, but what we want you to do is to think about all the different ways and which one's going to suit your work, and indeed might actually create other ways of doing it yourself.

So that these are just a few different ways of doing it.

I'm sure you'll be able to come up with more yourself.

We're gonna use Tinkercad to code the micro:bit and the alarm components.

We're going to show some of the coding blocks that you are going to be using today.

So, some of the coding blocks we are going to use in the examples.

We are gonna be using on shake and on pin.

So on shake, when the micro:bit is moved or shaken, then something will happen.

And this uses the micro:bit accelerometer, for example.

So when it is shaken, the accelerometer recognises that the micro:bit has been shaken or moved, and then it will signal it to do something.

On pin, now this is where an offboard input will signal the micro:bit to do something.

So again, it's telling the micro:bit to do something if an input does something.

So the input for on shake is the accelerometer notice some movement, whereas the input of the pin, so that's something you actually attach to those gold pins at the bottom, if that does something, then it signals the micro:bit to actually do something.

Now, both of these blocks can be found in the Inputs block in Tinkercad circuits.

We are also gonna be thinking about the repeat and button A pressed.

So repeat, that basically means that the micro:bit's told you need to be doing something while or until something is changed.

So keep repeating, keep repeating, keep repeating until, or while, something is changed.

And this is found in the control blocks.

Button A pressed.

When button A is pressed, the micro:bit will then do something.

And that's found within the inputs block in Tinkercad.

And you can see how in the repeat one you've got that hexagonal green button, and that's where the button A press can actually be dragged into.

We'll come onto that in a moment.

Check for understanding.

Which of the following blocks uses the micro:bit accelerometer.

Is it A, B or C? That's correct.

It's A.

Well done.

So, some more coding blocks to use in Tinkercad and this is where we can combine coding blocks.

So there we've got repeat until.

Well we've clicked repeat until rather than repeat while, and this coding block's been changed so that it'll repeatedly do something until the green coding block signals it to stop.

So if button A is pressed, then it will stop and it will do something else.

So button A pressed, this block replaces the true and I said we'll talk about that in a second.

Well, here it is.

We've just dragged that hexagonal green button into the repeat until block.

Here's some more coding blocks to use in Tinkercad.

This is the wait block.

Now you see you can got wait 1 sec.

So that means the micro:bit will not do anything for 1 second.

And then we've got wait 1 millisecond, and the micro:bit will not do anything for 1 millisecond.

Now of course you can change the number of seconds or milliseconds.

Remember 500 milliseconds is 1/2 a second.

We don't manage to do 1/2 a second, but we can put in it as 500 milliseconds.

And to do that you just click on the number that's there where it says "1" and then you just type in the number that you want.

These blocks are found within the Control blocks in Tinkercad circuits.

Okay, two more.

Now these are outputs.

This is a clear screen and show leds.

Show leds, the micro:bit will then show a design on the LED screen.

And clear screen, the micro:bit will then clear the LED screen.

And these are found in the Output blocks in Tinkercad circuits.

So which of the following blocks is an output? Is it A, B, or C? That's right, well done.

It's B.

Show leds is an output.

Now there are many different combinations of inputs and outputs that can be used with a micro:bit, but they do all need coding.

The next few slides we're gonna show some combinations of those codes for the different combinations of museum alarm components.

But as we've said, there's so many other different combinations that you can create, and there's so many different types of coding.

We're just going to give you just a few different types.

So, here's the first one.

So this is an onboard accelerometer.

An onboard LED alarm system.

And that's what it would look like is literally just using the micro:bit as the input and as the output.

So what's going to happen is, if the micro:bit is moved, then the alarm system on the LED screen will then signal.

But what does that look like in the coding? Well, this is the coding, and we go through this step by step.

So the accelerometer measures if the micro:bit and artefact are moved, then the LEDs will flash on and off for 500 milliseconds.

We had thought about thinking about just doing it for one second, but it doesn't seem to have the same impact as doing it for 1/2 a second.

So the X will flash on and off for 500 milliseconds, and that is until button A is pressed.

What happens is that button A deactivates the alarm.

So the alarm will stop as soon as button A is pressed.

Okay, so which code should be replaced by a repeat code to make the accelerometer code work in this piece of code? Should it be on shake, if button A pressed then, show leds, or clear screen? You can see on the picture there we've got the repeat until button A pressed.

Where should that go in this code? What should it replace? And if you think very carefully, it looks very similar to one of the other coding blocks that's there, and that would be the answer.

So which one do you think it is? A, B, C, or D? That's right.

Well done.

It's if button A pressed then.

We don't want an if code, we want to repeat until code.

So that is what is needs to be replaced by.

And this is what it should look once it's been replaced.

So that is the correct code, and that code will work.

The other code won't work quite as well or as effectively as the one that we've got here.

Well done.

Right, we're onto our next example now.

So we've got an onboard accelerometer again, but this time we've got an offboard piezo buzzer system, and that's what it's going to look like as a physical model.

So you've got your offboard buzzer, and then you've got your onboard accelerometer.

So if it moves, then the buzzer will sound.

And this is what it looks like with the code.

And again, we'll go through this step by step.

So the accelerometer measures when the micro:bit and the artefact are moved.

Then the LEDs flash.

So we're still having the LEDs flash, but the buzzer also turns on and off every 500 milliseconds.

And we can see that in the digital write pin P0 coding.

And that's where it says HIGH and LOW.

And of course pressing button A will deactivate the alarm.

A bit more complicated this one because we're now bringing in the pins, but we're just adding a little bit extra to the code that we've already had with the onboard accelerometer example in the example number one.

On to the next one.

This time we've got an offboard push-to-make switch and an onboard LED alarm system.

That's what it will look like.

We've got the switch, and we've got the LED alarm system that's gonna be on the micro:bit.

Here's the code.

So, the push-to-make switch uses pin 0 when pushed.

So this is the pin, the the pin 0, and that's what the push-to-make switch is attached to.

And then when it's pushed, then it'll signal the micro:bit to do something.

And the LEDs are gonna flash on and off again for 500 milliseconds.

And again, pressing button A deactivates the alarm.

Now, quick check for understanding.

Which of these is the physical model of an offboard push-to-make switch with an onboard LED display.

Think very carefully.

We've got one offboard component, that's the push-to-make switch, and the onboard LED display.

Which of these is the correct answer? Is it A, B, or C? That's correct, it's C.

And if you look very carefully, A has actually got the buzzer attached, and this one that we are not asking for the buzzer.

B hasn't got anything attached.

No offboard components at all.

C has got the offboard push-to-make switch attached.

Okay, onto our last example now.

And these are two offboard components.

This is the offboard push-to-make switch, and an offboard buzzer as well.

That's what it looks like.

And you can see there that you've got the buzzer is actually attached, and the push-to-make switch is also attached.

You can see where those are linked.

And here we've got our code.

So, let's go through it.

The push-to-make switch uses pin 0, and when that's pushed, that then signals a micro:bit to do something.

So that's your input, That's the on pin 0 change to HIGH.

So when that is connected then it will signal the micro:bit to do something.

And what it's gonna signal it to do is to flash the LEDs X again every 500 millisecond, but also it's going to have the buzzer turning on and off every 500 milliseconds.

And there you can see digital write pin 1.

So this time we've now got the buzzer is actually attached to pin 1, not pin 0 because, of course, the switch is actually connected to pin.

So pin 1 is the buzzer, and that will sound on and off just as the alarm, so the buzzer will sound on and off and the LEDs will come on and off as well.

And of course, as with all the other ones, pressing button A deactivates the alarm.

Now let's go through an example now of what Jacob has gone through and what he's decided to do.

So he's chosen to use an offboard push-to-make switch as an input, and an offboard buzzer.

Remember, those are two offboard components.

So he used the code and saved it in Tinkercad.

And now he's ready to download the code onto the micro:bit that's installed into his museum prototype.

So what he needs to do is to connect the micro:bit to the computer using a data cable.

Then you should see the micro:bit drive appears in the computer folders.

So we need to download the code from Tinkercad, and you can see where it quite clearly says Download Code.

And then that micro:bit programme will be found in the computer Downloads button.

What Jacob then needs to do is to copy and drag the HEX file to the micro:bit.

And then you'll notice that that's downloading because the micro:bit LED will start flashing yellow.

And when it's finished flashing yellow, then you know that it's completed.

You then disconnect the micro:bit from the computer, attach the battery pack, and then test the programme to make sure it works.

Okay, check for understanding now.

What type of file is downloaded onto the micro:bit? Is it A a BEX file, B, a DEX file, C, a GEX file, or D, a HEX file? Which do you think is the type of file downloaded onto the micro:bit, A, B, C, or D? That's right, well done.

It's D, it's a HEX file.

Okay, it's now your turn.

Now we've gone through four examples in step by step of the different inputs and outputs, and how to code them within Tinkercad.

Here it's now your chance.

Now, if you wanted to use one of the four examples that we've done, that's absolutely fine.

It depends upon the inputs and outputs you've chosen.

You can use the ideas that we've provided and actually go off in your own direction as well.

But little hints is to make sure you get the pins correct.

So, which pins are you gonna be using on the micro:bit.

If you're using the offboard components at all, indeed, 'cause you might not be needing to use any of the pins.

Anyway, I'm gonna stop talking.

We'll go through these six key steps for you to be successful in this task.

Number one.

So you need to create your code for a museum alarm in Tinkercad.

Two, you're gonna connect the micro:bit to a computer.

You are then three, gonna download the programme, download the HEX file to the micro:bit.

Then you are going to disconnect the micro:bit from the computer.

You are gonna then safely add a battery pack, and then you're gonna add cells to the battery pack if they aren't already in there.

All right, I'll leave you to get on.

You'll need a lot of time.

Be very careful.

Keep checking your your code to make sure that it's correct, and I'll leave you to it, right? Well done in advance, and I look forward to giving you some feedback in a few minutes.

All right, off you go.

Right, welcome back.

Jacob created his code, and he downloaded it onto the micro:bit.

So he created the code in Tinkercad, connected a micro:bit to a computer, downloaded the programme to the micro:bit, then disconnected the micro:bit, added a battery pack, and then added the cells.

And we're onto learning cycle two.

So now we're gonna be testing the circuits and the programmes.

By now you should have a HEX file downloaded onto a micro:bit.

It's now time to make sure that it works.

So we're gonna follow Jacob and his progress.

So he's making an alarm using an offboard push-to-make switch and an offboard buzzer.

Remember he's using just offboard components.

He wants to test it before making the final touches.

So he downloads the code.

He connects the components together.

Unfortunately it doesn't work.

So what he to do is to think logically to find out what the fault is.

So the first thing that he did was he checked the cells in the battery pack to see if they were working.

And what he did was he just connected a different component to the battery pack.

The battery pack wasn't hot and it did work when it was connected to a different component.

So he knows that the battery pack is not faulty.

If the battery pack does become hot or the cells do need checking, it is worth asking an adult for help with this.

Jacob then checked that the buzzer worked on its own with the battery pack and nothing else.

And it didn't work.

So when he connected it to the battery pack, the buzzer didn't work, then he swapped the wires over and the buzzer did work.

So actually the buzzer is not faulty, but what he's learnt is to make sure that he's got the wires the correct way round when he's adding it to the battery pack.

He then added a push-to-make switch with the buzzer and the battery pack, but without the micro:bit, and the switch didn't work at first.

He checked the wires, and they'd come loose.

So where the split pin was on the push-to-make switch, one of the wires had come loose, and so he needed to make sure that he addressed that, and then he found out that actually it all worked and the push-to-make switch was not faulty.

Now, let's have a look at this circuit.

What could be the fault in this circuit? Is it A, the bulb is broken.

B, the buzzer wires need swapping.

C, there aren't any cells.

Or D, the green wire is only attached on one end.

Which is the fault in this circuit, A, B, C, or D? That's right, well done.

It's B.

A, there is no bulb.

C, there are two cells already in the battery packs so we know that they're there.

And D, there is no green wire there.

So it is about the buzzer wires need swapping over.

So, let's follow Jacob again.

He's added the micro:bit.

He's noticed that the wires connected to the micro:bit pins keep coming loose.

So he checked the wires that they were connected to the correct pins.

He then checked that the wires were attached securely, and he found out that actually the wires were not faulty, it's just that one of them had kept loose.

So he was still double checking everything, and it's still not working.

So the wires have been checked, the cells have been checked, the components have been checked.

So, what is the problem? He's decided it's got to be something to do with the micro:bit and he needs to check the coding.

So he opened up Tinkercad again and he checked his coding.

And what he noticed was that actually he selected the wrong pin in his coding.

He's got pin 0 when actually he wanted pin 1.

And what he's done is he's changed the coding and downloaded the new HEX file.

You might notice that actually this is a different code to one that we used in learning cycle one, and that's absolutely fine.

If you've got a different code, you really do need to make sure that you've checked that everything is correct and you've got the right pins in the right places.

Okay, so Jacob has now checked his coding, and he's downloaded the new HEX file onto the micro:bit.

Check for understanding.

What does it mean to fault find logically? Does it mean A, to randomly replace wires until it works.

B, to use clear steps to find out what's wrong in the circuit.

C, to guess where the problem might be.

Or D, to blame the battery when something doesn't work.

Which do you think means to fault find logically, A, B, C, or D? That's right, well done.

It's B, using clear steps to find out what's wrong with the circuit.

Okay, now it's your turn.

So, test and check that your circuits and programme are working before adding them to the shoe box gallery.

Now it might be that they might not work, and if they don't work then you need to logically fault find.

So get your components, get the circuits, make sure you've downloaded the programme onto the micro:bit, which you should have done now as part of task A, and now it's a chance to actually test them before adding them to the shoe box gallery.

So you check the battery pack is safely attached, that the input might work on its own, the output works on its own, the input and the output work together, the wires are secure, and that the code is correct.

So if it doesn't work the way that you want, here's a list of six different things to go through just in case it doesn't work and to help you fault find.

All right, I'll let you get on now.

Test your circuits, test your programmes, let's see how you get on.

Okay, so Jacob tested and checked all the components and programmes before adding them to his gallery.

He went through logical fault finding.

He checked the battery pack was safely attached.

He checked that the input worked on its own, the output worked on its own, the input and the output worked together.

He checked the wires, and he checked that the code was correct.

And there he is.

He's actually thought about it and now it's working.

Okay, thank you for being with me today.

Let's go through a summary.

So, the first thing is that micro:bit alarm systems can be programmed in many ways using Tinkercad.

And I think there are so many different ways that you could do this.

When testing circuits, one component should be tested at a time.

There are many reasons why a circuit doesn't work.

And electrical components must have the correct current flow.

That means when we're talking about the buzzer, that needs to be the correct way round.

The wires need to be the correct way round for it to work.

Wonderful.

Well done.

Thank you very much for being with me today.

I'm sure you're really pleased with the way that things have gone.

And don't worry if you did find faults in your circuit, that's fine.

That's part of the learning.

It means you've been able to solve a problem, and that's really a strong piece of learning.

So, well done today.

Hope you've all had a lot of fun and that you've enjoyed working with micro:bits and Tinkercad coding, and I look forward to working with you next time.