Countdown to Christmas Makes Challenge 2017 – Day 16

Imperial March

For the BBC micro:bit

Programed in MicroPython

Imperial March theme tune for the BBC micro:bit, coded in MicroPython.

To start the music, just press the A button on your BBC micro:bit and it will play once. To play again, just press the button once more. If you would like the music to play continuously just remove or comment out line 19; if button_a.is_pressed():.

For details on how to connect headphones to your BBC micro:bit, check out Day 1 of my Countdown to Christmas Makes Challenge 2017.

MicroPython Code

# Imperial March
# @KariLawler (Twitter), 16/Dec/17, v1.0
from microbit import *
import music

imperial_march = [
    'a3:4', 'a3:4', 'a3:4', 'f3:3', 'c4:1',
    'a3:4', 'f3:3', 'c4:1', 'a3:8',
    'e4:4', 'e4:4', 'e4:4', 'f4:3', 'c4:1',
    'ab3:4', 'f3:3', 'c4:1', 'a3:8',  
    'a4:4', 'a3:3', 'a3:1', 'a4:4', 'ab4:3', 'g4:1', 
    'gb4:4', 'r:2', 'bb3:2', 'eb4:4', 'd4:3', 'db4:1', 
    'c4:4', 'r:2', 'f3:2', 'ab3:4', 'f3:3', 'a3:1',  
    'c4:4', 'a3:3', 'c4:1', 'e4:8'

music.set_tempo(bpm = 100)
while True:
    if button_a.is_pressed():

Leave a Reply