Wearables Lösung: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
| Zeile 11: | Zeile 11: | ||
[[Datei:Beim_Start_LED.jpg|right|500px|border0px|Beim Start]] | [[Datei:Beim_Start_LED.jpg|right|500px|border0px|Beim Start]] | ||
<pre id="01"> | |||
let strip: neopixel.Strip = null | let strip: neopixel.Strip = null | ||
basic.showIcon(IconNames.SmallHeart) | basic.showIcon(IconNames.SmallHeart) | ||
| Zeile 17: | Zeile 17: | ||
strip.setBrightness(50) | strip.setBrightness(50) | ||
</pre> | </pre> | ||
* Anzeige bei "wahr" - steht für Kopf | * Anzeige bei "wahr" - steht für Kopf | ||
Version vom 28. Dezember 2021, 12:22 Uhr
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