Morse Code Micro:Bit!

The Morse Code Micro:Bit displays text on the screen and translates it into morse code!

The Code!

let currentChar: int8[] = []

let text = 'Hello World'

let translation = text.toLowerCase()

let dictionary = [

[0,],

[1, 0, 0, 0],

[1, 0, 1, 0],

[1, 0, 0],

[0],

[0, 0, 1, 0],

[1, 1, 0],

[0, 0, 0, 0],

[0, 0],

[0, 1, 1, 1],

[1, 0, 1],

[0, 1, 0, 0],

[1, 1],

[1, 0],

[1, 1, 1],

[0, 1, 1, 0],

[1, 1, 0, 1],

[0, 1, 0],

[0, 0, 0],

[1],

[0, 0, 1],

[0, 0, 0, 1],

[0, 1, 1],

[1, 0, 0, 1],

[1, 0, 1, 1],

[1, 1, 0, 0]]

let alphabet = [

"A",

"B",

"C",

"D",

"E",

"F",

"G",

"H",

"I",

"J",

"K",

"L",

"M",

"N",

"O",

"P",

"Q",

"R",

"S",

"T",

"U",

"V",

"W",

"X",

"Y",

"Z"

]

basic.showString(text)

for (let i = 0; i < translation.length; i++) {

for (let o = 0; o < alphabet.length; o++) {

if (translation[i] == alphabet[o].toLowerCase()) {

basic.showString(alphabet[o])

for (let n = 0; n < dictionary[o].length; n++) {

if (dictionary[o][n] == 0) {

music.playTone(262, music.beat(BeatFraction.Half))

basic.pause(100)

}

if (dictionary[o][n] == 1) {

music.playTone(262, music.beat(BeatFraction.Whole))

basic.pause(100)

}

}

}

}

}