A learning resource from Spread Robotics Education Foundation

Lesson 02 · 55 minutes · Simple animation

Make the heart beat

Two pictures shown in order can look like movement. Add a pause and repeat the sequence to make an animation.

New programming concepts

Sequence, pause, and loop

First show a large heart. Then show a small heart. Pause between them and repeat. Your eyes join the pictures together into a heartbeat.

Large heart
Pausemilliseconds
Small heart
Sequence steps in an orderPause wait for a momentLoop repeat instructions

Try it here

Change the heartbeat speed

AB

How long should the program pause?

Pause: 500 milliseconds

MakeCode steps

Build the animation

  1. 1

    Open a new project

    Name it Beating Heart.

    Open MakeCode
  2. 2

    Use the forever block

    Your animation needs to repeat, so build the sequence inside the forever block.

  3. 3

    Show the large heart

    From Basic, add show icon and choose the large heart.

  4. 4

    Pause for 500 ms

    Add a pause (ms) block. Keep the number at 500. That is half a second.

  5. 5

    Show the small heart

    Add another show icon block and choose the small heart.

  6. 6

    Pause again

    Add another 500 ms pause. Test the complete sequence in the simulator.

    forever
    show icon ♥
    pause (ms) 500
    show icon ♥
    pause (ms) 500
  7. 7

    Download and test

    When the simulator works, transfer the program using the same steps as the Heart lesson.

Ready for one careful experiment?

Change both pauses to 1,000 ms. What changes? Then try 250 ms. Change one value at a time, observe, and explain the result.

Optional videos

Watch the official guides

The written steps above are complete. Videos are optional when the internet connection allows.

Visit the official Beating heart project

For the teacher

A calm 55-minute plan

Recall
Rebuild the single heart orally.

Unplugged animation
Alternate two paper heart pictures.

Guided build
Stop after each picture and pause.

Test and transfer
Use the simulator before USB.

One experiment
Change both pause values together.

Success criteria and accessibility note

A team succeeds if the two images repeat in the simulator and learners can point to the order. Do not require the word “iteration.” The page animation stops for people who request reduced motion; teachers should also warn learners who are sensitive to flashing lights.

Before you finish

Can you explain it?