- BBC Microbit
- EnviroBit extension
- Bluetooth extension
-
Buttons
- A: Temperature in C
- B: Pressure in in mm
-
Clap once for Temperature
-
Clap twice for Pressure
Device advertises a URL to this documentation
let t = 0 | |
let claps = 0 | |
input.onButtonPressed(Button.A, function () { | |
basic.showString("" + `T: ${tm}`) | |
}) | |
input.onButtonPressed(Button.B, function () { | |
basic.showString("" + `P: ${p}`) | |
}) | |
envirobit.onClap(function () { | |
claps += 1 | |
}) | |
let tm = 0 | |
let p = 0 | |
bluetooth.advertiseUrl( | |
"https://bit.ly/2HMjRA0", | |
7, | |
false | |
) | |
control.inBackground(function () { | |
p = envirobit.getPressure() | |
tm = envirobit.getTemperature() | |
}) | |
basic.forever(function () { | |
t = envirobit.timeSinceLastClap() | |
if (t > 2000) { | |
basic.showIcon(IconNames.Asleep) | |
} else if (t > 500) { | |
if (claps > 1) { | |
basic.showString("P: " + p) | |
} else if (claps == 1) { | |
basic.showString("T: " + tm) | |
} | |
claps = 0 | |
} | |
}) |