Created
August 23, 2018 17:27
-
-
Save baobao/cf8971c7c66a563ee0bea1d622f0838e to your computer and use it in GitHub Desktop.
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
// 送信側 | |
radio.setGroup(1) | |
input.onButtonPressed(Button.A, () => { | |
radio.sendString("A") | |
}) | |
input.onButtonPressed(Button.B, () => { | |
radio.sendString("B") | |
}) | |
input.onButtonPressed(Button.AB, () => { | |
radio.sendString("AB") | |
}) | |
let isPined0 = false | |
let isPined1 = false | |
let isPined2 = false | |
let threashold = 5 | |
let pin0 = 0 | |
let pin1 = 0 | |
let pin2 = 0 | |
basic.forever(() => { | |
pin0 = pins.analogReadPin(AnalogPin.P0) | |
pin1 = pins.analogReadPin(AnalogPin.P1) | |
pin2 = pins.analogReadPin(AnalogPin.P2) | |
if (pin0 == 0 && pin1 == 0 && pin2 == 0) { | |
return; | |
} | |
if (pin0 < threashold && isPined0 == false) { | |
isPined0 = true; | |
radio.sendString("0") | |
} else if (pin0 >= threashold) { | |
isPined0 = false; | |
} | |
if (pin1 < threashold && isPined1 == false) { | |
isPined1 = true; | |
radio.sendString("1") | |
} else if (pin1 >= threashold) { | |
isPined1 = false; | |
} | |
if (pin2 < threashold && isPined2 == false) { | |
isPined2 = true; | |
radio.sendString("2") | |
} else if (pin2 >= threashold) { | |
isPined2 = false; | |
} | |
console.log(pin0.toString() + "/" + pin1.toString() + "/" + pin2.toString()) | |
//basic.showString(pin0.toString() + " " + pin1.toString() + " " + pin2.toString()) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment