Code en JavaScript
Code Microbit 1:
input.onButtonPressed(Button.A, function () {
radio.sendNumber(cmp)
basic.showLeds(`
. . # . .
. . # . .
# . # . #
. # # # .
. . # . .
`)
basic.showLeds(`
. . . . .
. . # . .
. . # . .
# . # . #
. # # # .
`)
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . # . .
# . # . #
`)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . # . .
. . # . .
`)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . # . .
`)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
})
input.onGesture(Gesture.LogoUp, function () {
basic.clearScreen()
pause2 = cmp * 1000 / 10
radio.sendValue("up", pause2)
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
. . # . .
`)
basic.pause(pause2)
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
. . # . .
`)
basic.pause(pause2)
basic.showLeds(`
. . . . .
# # # # #
# # # # #
# # # # #
. . # . .
`)
basic.pause(pause2)
basic.showLeds(`
. . . . .
# # # # #
# # # # #
# # # # #
. . # . .
`)
basic.pause(pause2)
basic.showLeds(`
. . . . .
. . . . .
# # # # #
# # # # #
. . # . .
`)
basic.pause(pause2)
basic.showLeds(`
. . . . .
. . . . .
# # # # #
# # # # #
. . # . .
`)
basic.pause(pause2)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
# # # # #
. . # . .
`)
basic.pause(pause2)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. # # # .
. . # . .
`)
basic.pause(pause2)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . # . .
`)
basic.pause(pause2)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . # . .
`)
basic.pause(pause2)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
})
input.onButtonPressed(Button.AB, function () {
radio.sendString("reset")
basic.showIcon(IconNames.SmallSquare)
basic.pause(100)
basic.showIcon(IconNames.Square)
basic.clearScreen()
control.reset()
})
input.onButtonPressed(Button.B, function () {
cmp += 1
basic.showNumber(cmp)
})
radio.onReceivedValue(function (name, value) {
if (name == "down") {
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
basic.showLeds(`
. . # . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
basic.pause(value)
basic.showLeds(`
. # # # .
. . . . .
. . . . .
. . . . .
. . . . .
`)
basic.pause(value)
basic.showLeds(`
# # # # #
. . # . .
. . . . .
. . . . .
. . . . .
`)
basic.pause(value)
basic.showLeds(`
# # # # #
. # # # .
. . . . .
. . . . .
. . . . .
`)
basic.pause(value)
basic.showLeds(`
# # # # #
# # # # #
. . # . .
. . . . .
. . . . .
`)
basic.pause(value)
basic.showLeds(`
# # # # #
# # # # #
. # # # .
. . . . .
. . . . .
`)
basic.pause(value)
basic.showLeds(`
# # # # #
# # # # #
# # # # #
. . # . .
. . . . .
`)
basic.pause(value)
basic.showLeds(`
# # # # #
# # # # #
# # # # #
. # # # .
. . . . .
`)
basic.pause(value)
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
. . # . .
`)
basic.pause(value)
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
. # # # .
`)
basic.pause(value)
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)
}
})
let pause2 = 0
let cmp = 0
radio.setGroup(1)
cmp = 0
Code Microbit2:
radio.onReceivedNumber(function (receivedNumber) {
pause2 = receivedNumber * 1000 / 10
basic.showLeds(`
. . # . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
basic.showLeds(`
. # # # .
. . # . .
. . . . .
. . . . .
. . . . .
`)
basic.showLeds(`
# . # . #
. # # # .
. . # . .
. . . . .
. . . . .
`)
basic.showLeds(`
. . # . .
# . # . #
. # # # .
. . # . .
. . . . .
`)
basic.showLeds(`
. . # . .
. . # . .
# . # . #
. # # # .
. . # . .
`)
basic.clearScreen()
})
radio.onReceivedString(function (receivedString) {
basic.showIcon(IconNames.SmallSquare)
basic.pause(100)
basic.showIcon(IconNames.Square)
basic.clearScreen()
control.reset()
})
radio.onReceivedValue(function (name, value) {
if (name == "up") {
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . # . .
`)
basic.pause(value)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. # # # .
`)
basic.pause(value)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . # . .
# # # # #
`)
basic.pause(value)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. # # # .
# # # # #
`)
basic.pause(value)
basic.showLeds(`
. . . . .
. . . . .
. . # . .
# # # # #
# # # # #
`)
basic.pause(value)
basic.showLeds(`
. . . . .
. . . . .
. # # # .
# # # # #
# # # # #
`)
basic.pause(value)
basic.showLeds(`
. . . . .
. . # . .
# # # # #
# # # # #
# # # # #
`)
basic.pause(value)
basic.showLeds(`
. . . . .
. # # # .
# # # # #
# # # # #
# # # # #
`)
basic.pause(value)
basic.showLeds(`
. . # . .
# # # # #
# # # # #
# # # # #
# # # # #
`)
basic.pause(value)
basic.showLeds(`
. # # # .
# # # # #
# # # # #
# # # # #
# # # # #
`)
basic.pause(value)
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)
}
})
input.onGesture(Gesture.LogoDown, function () {
basic.clearScreen()
radio.sendValue("down", pause2)
basic.showLeds(`
# # # # #
# # # # #
# # # # #
# # # # #
# # # # #
`)
basic.showLeds(`
. . # . .
# # # # #
# # # # #
# # # # #
# # # # #
`)
basic.pause(pause2)
basic.showLeds(`
. . # . .
# # # # #
# # # # #
# # # # #
# # # # #
`)
basic.pause(pause2)
basic.showLeds(`
. . # . .
# # # # #
# # # # #
# # # # #
. . . . .
`)
basic.pause(pause2)
basic.showLeds(`
. . # . .
# # # # #
# # # # #
# # # # #
. . . . .
`)
basic.pause(pause2)
basic.showLeds(`
. . # . .
# # # # #
# # # # #
. . . . .
. . . . .
`)
basic.pause(pause2)
basic.showLeds(`
. . # . .
# # # # #
# # # # #
. . . . .
. . . . .
`)
basic.pause(pause2)
basic.showLeds(`
. . # . .
# # # # #
. . . . .
. . . . .
. . . . .
`)
basic.pause(pause2)
basic.showLeds(`
. . # . .
# # # # #
. . . . .
. . . . .
. . . . .
`)
basic.pause(pause2)
basic.showLeds(`
. # # # .
. . . . .
. . . . .
. . . . .
. . . . .
`)
basic.pause(pause2)
basic.showLeds(`
. . # . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
basic.pause(pause2)
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
})
let pause2 = 0
radio.setGroup(1)
No comments:
Post a Comment