How fast is your heart beat?
This lesson we will expand on the LED matrix by creating heart symbol. We will also explore the pause coding block as well as switching the LED's off using the clear screen block
Last updated
This lesson we will expand on the LED matrix by creating heart symbol. We will also explore the pause coding block as well as switching the LED's off using the clear screen block
Last updated
You will need to explain to the kids how something would blink. This is normally done by switch a light on and off continuously. Give them an example of switching the lights off and on at home.
You will also need to explain that the show icon block does as well as the clear screen block.
You may also need to explain to the kids how multiple block are executed one at a time, from top to bottom.
The show icon block is same like the show led block, when you select the drop down you can show the kids the different types of icons.
The clear screen simply puts all the LED's off
Click on the home button on the top of the MakeCode editor
Click on New Project
You should have a new project created.
Click on the Basic category and drag the show icon code block to the forever block
Look at the simulator, you will see a heart displayed on the LED screen. You will also notice that the heart does not blink. In order for the heart to blink, all the LED's that are ON needs to be switch off, then back on again. Similar to when you switch your lights on and off at home.
To switch off all the LED's you can use the clear screen block.
To select the clear screen block, click on Basic, then more. You will then see the clear screen block.
Drag the clear screen block and place it under the show icon block.
The simulator will now show the heart that is blinking.
The way this works is, first the show icon block code will run and show the LED's on the screen. Then the clear screen block will run and switch all the LED's off. This will then repeat as it is in the forever block. So the forever block means your code will loop over and over again.
You will notice that the heart beat is very fast. We we need to slow it down. In order for us to do this, we need to pause for a moment.
In order or us to pause in our program, we will need to use the pause block.
This can be found under Basic, and pause
Drag the pause block and place it underneath the clear screen block
Click in the arrow on the pause block and you will see different time options, select 2 seconds
If you look at the simulator, you will now see that the heart is blinking slower.
Pair your device and Click Download
Your device will now blink an heart.
If you have some time, ask the kids to play around with the different icons