Created
May 14, 2020 09:14
-
-
Save damiensawyer/a35c3f1415102cbaba2539aa4b9c9cf5 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
control.onEvent(EventBusSource.MICROBIT_ID_BUTTON_AB, EventBusValue.MICROBIT_BUTTON_EVT_CLICK, function () { | |
if (Button_B_state == 1) { | |
Button_B_state = 0 | |
setNose() | |
} else { | |
Button_B_state = 1 | |
setNose() | |
} | |
radio.sendValue("Lights", Button_B_state) | |
}) | |
control.onEvent(EventBusSource.MICROBIT_ID_BUTTON_B, EventBusValue.MICROBIT_BUTTON_EVT_CLICK, function () { | |
if (face == 1) { | |
face = 0 | |
basic.showIcon(IconNames.Happy) | |
setNose() | |
} else { | |
face = 1 | |
basic.showIcon(IconNames.Sad) | |
setNose() | |
} | |
radio.sendValue("Face", face) | |
}) | |
let face = 0 | |
let Button_B_state = 0 | |
radio.setGroup(1) | |
basic.showIcon(IconNames.Happy) | |
let setNose = () => { | |
if (Button_B_state == 1) | |
led.plot(2, 2) | |
else | |
led.unplot(2, 2) | |
} | |
basic.forever(function () { | |
if (input.buttonIsPressed(Button.A)) { | |
radio.sendValue("Pitch", input.rotation(Rotation.Pitch)) | |
radio.sendValue("Roll", input.rotation(Rotation.Roll)) | |
} else { | |
radio.sendValue("Pitch", 0) | |
radio.sendValue("Roll", 0) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment