Skip to content

Activity

Here comes the sun

Beginner | MakeCode, Python | LED display | Representation

Step 1: Make it

What is it?

Create your own sun icon for your micro:bit.

micro:bit showing sun-burst image on its LED display

How it works

  • The micro:bit has lots of pictures built in, but sometimes you’ll want to add your own.
  • This program creates a sun image using the micro:bit display's 5x5 grid of LEDs.
  • Computers, phones and tablets use small pictures to represent things and ideas using a small number of dots, or pixels, as icons or emojis.

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)
  • squared paper for drawing your own designs (optional)

Step 2: Code it

1from microbit import *
2
3while True:
4    display.show(Image(
5        "90909:"
6        "09990:"
7        "99999:"
8        "09990:"
9        "90909"))

Step 3: Improve it

  • Draw your own version of the sun, or a star or moon.
  • Make a sun appear if you press button A, a moon if you press button B.
  • Use a loop to make the sun blink or rise.
  • In Python, use a range of numbers (not just 9) to show the sun’s rays getting dimmer as they get further from the centre.