Lösung morse1: Unterschied zwischen den Versionen
| Zeile 5: | Zeile 5: | ||
* Anzeige eines einzelnen Morsesymbols | * Anzeige eines einzelnen Morsesymbols | ||
<prev id="01"> | <prev id="01"> | ||
input.onButtonPressed(Button.A, function () { | input.onButtonPressed(Button.A, function () { | ||
Version vom 21. September 2021, 13:24 Uhr
Hilfestellung
Detailschritte
- Anzeige eines einzelnen Morsesymbols
<prev id="01"> input.onButtonPressed(Button.A, function () {
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
}) input.onButtonPressed(Button.B, function () {
basic.showLeds(`
. . . . .
. . . . .
. . . . .
. . . . .
. . . . .
`)
basic.showString("-")
}) basic.showLeds(`
. . # . . # # # # # . . # . . . # . # . # . . . # `)
</prev>
- Verbindung von 2 Micro:bits
<prev id="01"> input.onButtonPressed(Button.A, function () {
basic.showString("Hello!")
}) radio.onReceivedString(function (receivedString) {
basic.showString(receivedString)
}) radio.setGroup(25) </prev>
- Senden von Nachrichten:
Beide Micro:bit können bei diesem Beispiel densselben Programmcode verwenden <prev id="01"> input.onButtonPressed(Button.A, function () {
radio.sendString("Hallo")
}) radio.onReceivedString(function (receivedString) {
basic.showString(receivedString)
}) radio.setGroup(25) </prev>
- Senden von Morsecode:
Beide Micro:bit können bei diesem Beispiel densselben Programmcode verwenden <prev id="01"> input.onButtonPressed(Button.A, function () {
radio.sendString(".")
}) radio.onReceivedString(function (receivedString) {
basic.showString(receivedString)
}) input.onButtonPressed(Button.B, function () {
radio.sendString("-")
}) radio.setGroup(25) </prev>
- Empfangen vcn Morsecodes mit Soundausgabe:
Beide Micro:bit können bei diesem Beispiel densselben Programmcode verwenden <prev id="01"> radio.onReceivedString(function (receivedString) {
if (receivedString.includes(".")) {
music.playTone(262, music.beat(BeatFraction.Whole))
basic.showLeds(`
. . . . .
. . . . .
. . # . .
. . . . .
. . . . .
`)
} else {
music.playTone(262, music.beat(BeatFraction.Breve))
basic.showString("-")
}
}) </prev>
- Eine mögliche Lösung