diff --git a/docs/projects/messenger.md b/docs/projects/messenger.md new file mode 100644 index 00000000..2de5ca75 --- /dev/null +++ b/docs/projects/messenger.md @@ -0,0 +1,65 @@ +# messenger + +![](/static/mb/projects/a9-radio.png) + +Use the radio to create an app that sends "YO" messages. + +## Step 1 + +Use [on button pressed](/reference/input/on-button-pressed) to send the number "0" over radio. + +```blocks +input.onButtonPressed(Button.A, () => { + radio.sendNumber(0); +}); +``` + +## Step 2 + +Use [radio on data received](/reference/radio/on-data-received) display "YO" when the number ``0`` is received +by radio. + +```blocks +let message = 0; +radio.onDataReceived(() => { + message = radio.receivedNumber(); + if (message == 0) { + basic.showString("YO") + } +}) +``` + +Compile the program and **upload the same .hex file to 2 devices!** + +## Step 3 + +Use [on button pressed](/reference/input/on-button-pressed) to send the number "1" over radio. + +```blocks +input.onButtonPressed(Button.B, () => { + radio.sendNumber(1); +}); +``` + +## Step 4 + +Add blocks in [radio on data received](/reference/radio/on-data-received) to display "BYE" when the number ``1`` is received +by radio. + +```blocks +let message = 0; +radio.onDataReceived(() => { + message = radio.receivedNumber(); + if (message == 0) { + basic.showString("YO") + } + if (message == 1) { + basic.showString("BYE") + } +}) +``` + + +```package +microbit-radio +``` diff --git a/docs/projects/telegraph-challenges.md b/docs/projects/telegraph-challenges.md index eb9a993c..7708cdbb 100644 --- a/docs/projects/telegraph-challenges.md +++ b/docs/projects/telegraph-challenges.md @@ -1,12 +1,12 @@ # telegraph activity -Build a telgraph. +Build a telegraph. # micro:bit telegraph Have you ever tried to communicate through a telegraph? Let's try coding a "Telegraph" on two BBC micro:bits ! -Complete the following [guided tutorial](/projects/telegraph), your hack should look like this: +Complete the following [tutorial](/projects/telegraph), your hack should look like this: ![](/static/mb/lessons/telegraph-0.png)