Wearables Lösung
Hilfestellung
- Für die Kopf-Seite der Münze kann der Wert "wahr" oder "falsch" genommen werden.
- Annahme: Kopf entspricht "wahr", Zahl entspricht "falsch"
Detailschritte
- Beim Start muss die Länge (=Anzahl der LEDs) und der PIN angegeben werden.
- TIPP: Das Herabsetzen der Helligkeit spart Strom.

let strip: neopixel.Strip = null basic.showIcon(IconNames.SmallHeart) strip = neopixel.create(DigitalPin.P0, 60, NeoPixelMode.RGB) strip.setBrightness(50)
- Anzeige bei "wahr" - steht für Kopf
- Anzeige bei "falsch" - steht für Zahl
- Anzahl muss mitgezählt werden
let anzahl_kopf = 0
let anzahl_zahl = 0
input.onGesture(Gesture.Shake, function () {
if (Math.randomBoolean()) {
anzahl_kopf += 1
basic.showLeds(`
. # . . #
. # . # .
. # # . .
. # . # .
. # . . #
`)
} else {
anzahl_zahl += 1
basic.showLeds(`
. # # # #
. . . . #
. . # # .
. # . . .
. # # # #
`)
}
})
- Anzahl wird jeweils ausgegeben
input.onButtonPressed(Button.A, function () {
basic.showNumber(anzahl_kopf)
})
input.onButtonPressed(Button.AB, function () {
basic.showNumber(anzahl_kopf + anzahl_zahl)
})
input.onButtonPressed(Button.B, function () {
basic.showNumber(anzahl_zahl)
})
- Nicht vergessen - Variablen auf 0 stellen
let anzahl_kopf = 0 let anzahl_zahl = 0
- Eine mögliche Lösung