Skip to content

Instantly share code, notes, and snippets.

@Xayer
Created November 19, 2019 18:17
Show Gist options
  • Save Xayer/4df5d941b3241949ef43df565ffa96d3 to your computer and use it in GitHub Desktop.
Save Xayer/4df5d941b3241949ef43df565ffa96d3 to your computer and use it in GitHub Desktop.
Microbit test code
const faces = {
initialize: [
`. . . . .
. # . # .
. . . . .
. . . . .
. . . . .
`,
`. . . . .
. # . # .
. . . . .
. . . . .
. . # . .
`,
`. . . . .
. # . # .
. . . . .
. . . . .
. # # # .
`,
`. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`,
],
neutral: [
`
. . . . .
. # . # .
. . . . .
. # # # .
. . . . .
`
],
happy: [
`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`
],
sad: [
`
. . . . .
. # . # .
. . . . .
. # # # .
# . . . #
`
],
};
function showFace(faces: Array<string>) {
helpers.arrayForEach(faces, (value: string, index: number) => {
const face = faces[index] as string;
basic.showLeds(face);
})
}
input.onGesture(Gesture.Shake, function () {
showFace(faces.neutral);
})
input.onGesture(Gesture.TiltLeft, function () {
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
basic.showLeds(`
. . . . .
# . # . .
. . . . .
# . . . #
. # # # .
`)
})
input.onGesture(Gesture.TiltRight, function () {
basic.showLeds(`
. . . . .
. # . # .
. . . . .
# . . . #
. # # # .
`)
basic.showLeds(`
. . . . .
. . # . #
. . . . .
# . . . #
. # # # .
`)
})
input.onButtonPressed(Button.B, function () {
})
input.onButtonPressed(Button.A, function () {
})
showFace(faces.initialize);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment