# Heartbeat Simulation - Student

In this activity, you will find and describe your heartbeat.

• How can you describe the rhythm of your heartbeat?

Now that you have found your heartbeat, you will learn how to find your pulse and calculate your resting heart rate:

• Find your pulse by placing two fingers over your wrist. Once you have found it, count the number of pulses in 15 seconds.
• Multiply this by 4 to calculate your resting heart rate in beats per minute (bpm).
• Optional: Do some sort of physical activity that gets your heart really pumping, like running on the spot for 1 minute. What is your heart rate now?

In this activity, you will code a heartbeat simulation using MakeCode and a micro:bit.

Instructions for this coding activity are in the video as well as in the chart below.

### Instructions

Once on http://makecode.microbit.org/ click on the New Project button under the heading My Projects.

You will see two blocks in the working area when you start a new project.
Delete the on start block. You can do this by right-clicking and choosing the Delete Block option or by dragging the block to the left over the menu where a trashcan will appear.

Under Basic, click and drag a show icon block inside of the forever block.

The show icon block defaults to an image of a big heart. If you click on the small downward arrow beside the heart, you will see all of the pre-made icons you can use.

Select the small heart (top row).

Under Basic, click and drag another show icon block beneath the first show icon block. It already has the big heart, which is what you want.
You should now see on the simulator micro:bit that the image switches between the little heart and the big heart.

To make this more like a real heartbeat, you can incorporate pause blocks. Under Basic, select a pause block. You will notice that the block looks different than the others.

Tip

A block will be “grayed out” until you place it in such a way that it can function.

Place a pause block after each heart icon. This will cause the hearts to remain displayed for a specific amount of time measured in milliseconds (ms). The default time is set to 100 ms.

Think about the sound of a heart beat (lub dub) and adjust the pause block values by clicking on each number. You can choose a value from the dropdown menu, or type in your own value.

Did you know?

1000 milliseconds = 1 second

Your final simulation should look something like this.

Plug the micro:bit in to your computer’s USB port using the micro USB cable that came with the micro:bit. The micro:bit should show up as a USB storage device, much in the same way as a flash drive.

Below the working area you will see a space beside the save icon where you can name your project.

Click on the pull down arrow beside the file name.