Skip to content

Instantly share code, notes, and snippets.

@yratof
Created December 22, 2016 21:46
Show Gist options
  • Save yratof/cbdd193c61f7f439ee60ba1a5d1dd88c to your computer and use it in GitHub Desktop.
Save yratof/cbdd193c61f7f439ee60ba1a5d1dd88c to your computer and use it in GitHub Desktop.
Bike indicators for Micro:bit
input.onButtonPressed(Button.A, () => {
radio.sendNumber(0)
for (let i = 0; i < 10; i++) {
basic.showLeds(`
. . # . .
. # . . .
# # # # #
. # . . .
. . # . .
`)
basic.clearScreen()
basic.pause(100)
}
})
input.onButtonPressed(Button.B, () => {
radio.sendNumber(1)
for (let i = 0; i < 10; i++) {
basic.showLeds(`
. . # . .
. . . # .
# # # # #
. . . # .
. . # . .
`)
basic.clearScreen()
basic.pause(100)
}
})
let direction = 0
radio.onDataPacketReceived(({receivedNumber}) => {
direction = receivedNumber
if (direction == 1) {
basic.clearScreen()
for (let i = 0; i < 10; i++) {
basic.showLeds(`
. . # . .
. . . # .
# # # # #
. . . # .
. . # . .
`)
basic.clearScreen()
basic.pause(100)
}
}
if (direction == 0) {
basic.clearScreen()
for (let i = 0; i < 10; i++) {
basic.showLeds(`
. . # . .
. # . . .
# # # # #
. # . . .
. . # . .
`)
basic.clearScreen()
basic.pause(100)
}
}
})
@yratof
Copy link
Author

yratof commented Jul 11, 2017

Utilises two micro bits with the same code as above. Each bit tells each other which arrow to display when you push the corresponding button.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment