Skip to content

Activity

Calming LEDs

Beginner | MakeCode, Python | LED display | 3 Health, Animation, Iteration, Sequence

Step 1: Make it

What is it?

Turn your micro:bit into a simple digital device to help you relax by slowing and regulating your breathing using a simple animation sequence.

This project is part of a series created to offer problem-solving and prototyping activities designed to explore technology as a solution to the challenges of the Global Goals for Sustainable Development.

Introduction

Coding guide

How it works

  • Build an animation sequence in a 'forever' loop to keep it running.
  • Use the large and small built-in diamond icons to create a pulsating effect.
  • Add pause blocks to slow down the animation to a relaxing pace.
  • Use a longer pause in the middle of the animation, perhaps 2 seconds which is 2000 milliseconds.
  • Test out your code in the MakeCode simulator to make sure it works the way you want before transferring it to your micro:bit.

What you need

  • micro:bit (or MakeCode simulator)
  • MakeCode or Python editor
  • battery pack (optional)

Step 2: Code it

1from microbit import *
2
3while True:
4    sleep(2000)
5    display.show(Image('00000:'
6                       '00000:'
7                       '00900:'
8                       '00000:'
9                       '00000'))
10    sleep(500)
11    display.show(Image.DIAMOND_SMALL)
12    sleep(500)
13    display.show(Image.DIAMOND)
14    sleep(2000)
15    display.show(Image.DIAMOND_SMALL)
16    sleep(500)
17    display.show(Image('00000:'
18                       '00000:'
19                       '00900:'
20                       '00000:'
21                       '00000'))
22
23

Step 3: Improve it

  • Change the pause times to match your own preferred pace of breathing.
  • Create your own images to replace the diamond icons.
  • Add more steps to make your animation smoother.