from microbit import * import random import music # indentations in text are important # Morse Code - letters # this is not efficient code by any means - you can do better! # speaker / headphones go between P0 and 0V (GND) # set morse speed 120 is slow 200 is fast music.set_tempo (bpm=220) # starts off with two runs of G3WOR then one every 10 mins sleep(1000) music.play(["C5:3","R:1", "C5:3", "R:1", "C5:1"]) display.show("G") music.play(["R:3"]) display.clear() music.play(["C5:1", "R:1", "C5:1", "R:1", "C5:1", "R:1", "C5:3", "R:1", "C5:3"]) display.show("3") music.play(["R:3"]) display.clear() music.play(["C5:1", "R:1", "C5:3", "R:1", "C5:3"]) display.show("W") music.play(["R:3"]) display.clear() music.play(["C5:3", "R:1", "C5:3", "R:1", "C5:3"]) display.show("O") music.play(["R:3"]) display.clear() music.play(["C5:1", "R:1", "C5:3", "R:1", "C5:1"]) display.show("R") music.play(["R:3"]) display.clear() sleep(2000) while True: # C5 is pitch of note, the 1 in C5:1 is the duration 1 = . dot (dit), 3 = - dash (dah) # R:1 is a pause equiv to a dot . sleep(1000) music.play(["C5:3","R:1", "C5:3", "R:1", "C5:1"]) display.show("G") music.play(["R:3"]) display.clear() music.play(["C5:1", "R:1", "C5:1", "R:1", "C5:1", "R:1", "C5:3", "R:1", "C5:3"]) display.show("3") music.play(["R:3"]) display.clear() music.play(["C5:1", "R:1", "C5:3", "R:1", "C5:3"]) display.show("W") music.play(["R:3"]) display.clear() music.play(["C5:3", "R:1", "C5:3", "R:1", "C5:3"]) display.show("O") music.play(["R:3"]) display.clear() music.play(["C5:1", "R:1", "C5:3", "R:1", "C5:1"]) display.show("R") music.play(["R:3"]) display.clear() # 1 min pause = sleep (60000) # 10 min pause = sleep (600000) sleep(600000)