Skip to content

Activity

Shining sunbeams

Beginner | MakeCode, Python | LED display | Iteration, Sequence

Step 1: Make it

What is it?

Use the sun icon from the Here comes the sun to make a sunbeam animation.

sun animation on micro:bit display

How it works

  • The program shows a sequence of sun pictures on the LED display based on the one we made in the Here comes the sun project.
  • It waits 500 milliseconds (half a second) between showing each image to allow you to see it before displaying the next.
  • The sequence makes an animation of sunbeams coming from the centre of the sun.
  • The sequence repeats for as long as your micro:bit has power because the instructions are inside a forever, or infinite, loop.
  • Computers are often used to help animators make cartoons and films, creating an illusion of movement by showing a sequence of slightly different images one after another.

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)
  • squared paper to sketch your own sunbeam designs (optional)

Step 2: Code it

Step 3: Improve it

  • Speed up or slow down the animation by changing the delay of 500 milliseconds.
  • Use your own design for the sun and its rays.
  • In Python, use a range of numbers from 1 to 9 to show the sun’s rays getting dimmer as they get further from the centre.