micro:bit — Basic Loops, Delays, and Button A Toggle MicroPython

Demonstrates while True: loops, sleep() timing, and using Button A to start/stop an animation.

SPEC

Success Criteria: Uses while True:, uses sleep() for timing, shows a repeating animation, and Button A cleanly starts/stops it.

Pseudocode

SET running = False

FOREVER:
  IF Button A was pressed:
      running = NOT running
      wait 300 ms (debounce)

  IF running is True:
      FOR each image in frames (4 images):
          show image
          wait 500 ms
  ELSE:
      clear display

MicroPython Program (copy to the micro:bit)

You need to research how to code this.

Tip: Adjust the delay (e.g., 500 → 200) to speed up the animation.

The name of the file will be:
PX_lastname_loops

Files to save on Google Drive under your class and submit to Google Classroom

  1. PX_lastname_loops.png — Screenshot inside Python editor showing your code.
  2. PX_lastname_loops.py — Your Python source file.
  3. PX_lastname_loops.txt — Plain-text copy of your code.
  4. PX_lastname_loops.hex — Hex file to run on the physical micro:bit.
  5. PX_lastname_loops.mp4 — Short demo video of the program running on the board.

Submission requirements