Loading...
Hello, I'm Mrs. Taylor, and thank you for joining me for our lesson today.
Today our lesson is Code and Simulate micro:bits in Tinkercad, and this is part of the Functional Prototypes: Wearable Technology unit.
The outcome, I can develop a light sequence control system, and test and iterate it.
There are three keywords: programme, which is a sequence of instructions that can be used to control electrical components; sensor, a device that can detect and monitor changes; and simulate, to imitate a product or process to test it.
The lesson has two parts, code a light sequence and downloading code to a micro:bit.
Let's get started with code a light sequence.
The micro:bit has several inputs and sensors which are built in: Button A, button B, and three connector pins, which can be used for inputs or outputs.
We can see more inputs and sensors on the reverse of the micro:bit: the processor and temperature sensor, the accelerometer, and the microphone.
Here we have a check for understanding.
Which built-in sensor detects heat? Is it A, processor and temperature sensor, B, microphone, or C, accelerometer? Pause the video and have a go.
Wonderful.
Let's check.
That's right, it's A, processor and temperature sensor.
Well done.
It also has several output devices built in: the LED matrix on the front; the three connector pins, which can be an input or an output; and on the back we can see a speaker.
When designing a control system using a micro:bit, a decision has to be made about whether to use the onboard and built-in inputs and outputs or the connector pins to connect components.
To programme the inbuilt LEDs to flash an X on and off, the code would look like this.
When button A is pressed, the LEDs show the X illuminated.
We wait one second and then the LEDs are off.
To make the alternating outputs repeat, we can add a repeat routine.
This is also known as a repeat loop.
It will execute the same code a set amount of times.
In this example, the output LEDs will flash on and off 10 times.
In this programme, the initial input is someone pressing button A.
We want the system to sense when to turn each output on.
Which component could be used to sense light levels? That's right.
It's a light dependent resistor, an LDR, can be used to sense light levels.
As the light levels increase, the resistance decreases.
The change in resistance can create a voltage change, which can be used as a signal to control an output.
Here we have a check for understanding.
If the light level decreases, what does the resistance of an LDR do? Is it A, stays the same, B, increases, or C, decreases? Pause the video and have a go.
Wonderful.
Let's check.
That's right, it's B, it increases.
Well done.
We could use an external LDR or the built-in light sensor.
This example uses the built-in light sensor.
To start this programme, we begin with an if statement.
If the light sensor has a light level greater than 100, the output sequence is triggered.
If the light level is less than 100, then the else sequence is triggered.
We now move to Task A.
With Tinkercad open, navigate using this link to the example Oak National Academy light level Micro:bit sequence.
Part two, open and simulate the system, and describe what happens when in the dark and when in the light.
Use the toggle to change the light levels.
And part three, amend the programme to show a different LED shape as the output, and change this to be off when it is light and on when it is dark, and explain how you did this.
Pause the video and have a go.
Wonderful.
Let's have a look at some of the answers you may have come up with.
Lucas says for part two, "When the system is in the dark and the light levels are below 100, nothing happens even when I press button A.
When the toggle is moved, so the system is in the light and the light levels are above 100, then the X flashes on and off 10 times." For part three, Lucas says, "I changed the LED shape to be a smiley face." And he also says, "I also changed the code to show the smiley face to be off when the light levels were higher than 100.
I did this by changing the greater than symbol to a less than symbol.
The smiley face was solid on when the light levels were less than 100." Well done.
We're now going to move to the second part of the lesson, downloading code to a micro:bit.
We have used the micro:bit simulation in Tinkercad to simulate programmable systems. This is a cost-effective and quick way to test and modify programmable systems. In order to integrate a micro:bit into a product or physical system, we need to download the programme to the physical micro:bit in the real world.
Here we have a check for understanding.
What are the advantages of simulating a programmable system virtually? Is it A, very expensive, B, cost effective, or C, quick? Pause the video and have a go.
Wonderful.
Let's check.
That's right, it's both B and C.
It is cost effective and quick.
Well done.
Before downloading a micro:bit programme, change the name of your file to include your name.
And you can see here where to do that.
Then press the Download button, which we can see here.
Here we have a check for understanding.
Which image shows the Download button in Tinkercad? Is it A, B or C? Pause the video.
Let's check.
Well done, that's right, it's A.
Now you have downloaded the code from Tinkercad to your computer, it's time to transfer this to the micro:bit.
Plug the micro:bit into the computer using a micro USB cable.
Drag the downloaded hex file into the micro:bit.
We now move to Task B.
Part one, download the programme you made in Task A.
Part two, transfer the download to your micro:bit.
Part three, test the programmable system in the real world and explain what went well and if there were any challenges.
Pause the video and have a go.
Wonderful.
Let's have a look at some of the answers you may have come up with.
Here we can see a picture of the micro:bit connected to the micro USB cable.
And part three, the download went well.
I'm glad I chose to use the built-in LEDs as this meant there were no messy wires to attach.
Well done.
Here we have a summary of our learning today.
Microcontrollers are small computers with inputs and outputs.
Microcontrollers can be programmed using blocks.
Repeat loops are useful for repeat parts of programmes.
Simulating programmable systems is a quick and easy way to test the system without having to buy in different components.
Downloading a programme to a micro:bit allows the micro:bit to be integrated into a product.
I'm really pleased you could join me for this lesson today.
Well done.