Created
August 7, 2020 02:55
-
-
Save baobao/45ff109c8762759ad3739cdd90b7331f to your computer and use it in GitHub Desktop.
Serial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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