Created
January 16, 2020 12:38
-
-
Save newbornfrontender/325a86efae5c6bd479c0970f29597071 to your computer and use it in GitHub Desktop.
microbit - temperature and accelerometer test
This file contains hidden or 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
const getTemperature = (): number => input.temperature(); | |
const printTemperature = (): void => basic.showNumber(getTemperature()) | |
const showIcon = (name: IconNames): void => basic.showIcon(name) | |
const isButtonPressed = (button: Button): boolean => input.buttonIsPressed(button) | |
basic.forever(() => { | |
const isAPressed = isButtonPressed(Button.A) | |
const isBPressed = isButtonPressed(Button.B) | |
if (isAPressed) printTemperature() | |
if (isBPressed) input.onShake(() => showIcon(IconNames.Heart)) | |
else if (!isBPressed) basic.clearScreen() | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment