Lösung morse1

Aus microbit - Das Schulbuch
Wechseln zu: Navigation, Suche

Hilfestellung

Detailschritte

  • Anzeige eines einzelnen Morsesymbols

input.onButtonPressed(Button.A, function () {
    basic.showLeds(`
        . . . . .
        . . . . .
        . . . . .
        . . . . .
        . . . . .
        `)
    basic.showLeds(`
        . . . . .
        . . . . .
        . . # . .
        . . . . .
        . . . . .
        `)
})
input.onButtonPressed(Button.B, function () {
    basic.showLeds(`
        . . . . .
        . . . . .
        . . . . .
        . . . . .
        . . . . .
        `)
    basic.showString("-")
})
basic.showLeds(`
    . . # . .
    # # # # #
    . . # . .
    . # . # .
    # . . . #
    `)


  • 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>

Zurück zur Aufgabe