Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Serial
// setup serial
serial.setBaudRate(BaudRate.BaudRate115200)
// 0:none, 1:Success, 2:Fail
basic.forever(function ()
{
let str = serial.readString()
if (str.indexOf("1") >= 0) {
basic.showIcon(IconNames.Heart)
basic.pause(1000)
} else if (str.indexOf("2") >= 0) {
basic.showIcon(IconNames.No)
basic.pause(1000)
} else if (str.indexOf("3") >= 0) {
basic.showLeds(`
. # # # .
# . . . #
. . # # .
. . # . .
. . # . .
`)
basic.pause(1000)
} else {
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
}
})
// debug
input.onButtonPressed(Button.A, function () {
basic.showIcon(IconNames.QuarterNote)
})
input.onButtonPressed(Button.AB, function () {
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment