Fixing parameters
This commit is contained in:
parent
aa6a965f59
commit
4941ce1694
@ -3,9 +3,10 @@
|
||||
Run part of a program when the micro:bit receives a
|
||||
[number](/reference/types/number) or [string](/reference/types/string) over ``radio``.
|
||||
|
||||
### Parameters
|
||||
|
||||
* the part of the program to run when the micro:bit receives information over ``radio``.
|
||||
```sig
|
||||
radio.onDataReceived(() => { });
|
||||
```
|
||||
|
||||
### Simulator
|
||||
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
Receives the next number sent by a micro:bit in the same ``radio`` group.
|
||||
|
||||
```sig
|
||||
radio.receiveNumber();
|
||||
```
|
||||
|
||||
### Returns
|
||||
|
||||
* the first [number](/reference/types/number) that the micro:bit received. If it did not receive any numbers, this function will return `0`.
|
||||
|
@ -8,7 +8,8 @@ radio.receiveString()
|
||||
|
||||
### Returns
|
||||
|
||||
* the first [string](/reference/types/string) that was sent. If no string was sent, then this function returns an empty (blank) string.
|
||||
* the first [string](/reference/types/string) that was sent. If no
|
||||
string was sent, then this function returns an empty (blank) string.
|
||||
|
||||
### Simulator
|
||||
|
||||
|
@ -8,6 +8,10 @@ the last time it ran the
|
||||
[receive number](/reference/radio/receive-number) function. That means
|
||||
it needs to run **receive number** first.
|
||||
|
||||
```sig
|
||||
radio.receivedSignalStrength();
|
||||
```
|
||||
|
||||
### Returns
|
||||
|
||||
* a [number](/reference/types/number) between `255` and `0` that means
|
||||
|
@ -1,10 +1,14 @@
|
||||
# Send Number
|
||||
|
||||
Broadcast a number to other micro:bits connected via ``radio``.
|
||||
Broadcast a [number](/reference/types/number) to other micro:bits connected via ``radio``.
|
||||
|
||||
```sig
|
||||
radio.sendNumber(0);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
* num - a number to send.
|
||||
* ``value`` - a [number](/reference/types/number) to send.
|
||||
|
||||
### Simulator
|
||||
|
||||
@ -12,9 +16,9 @@ This function only works on the micro:bit, not in browsers.
|
||||
|
||||
### Example: Broadcasting acceleration
|
||||
|
||||
This example broadcasts the value of your micro:bit's ``acceleration`` in the `x` direction
|
||||
(left and right) to other micro:bits.
|
||||
This kind of program might be useful in a model car or model rocket.
|
||||
This example broadcasts the value of your micro:bit's ``acceleration``
|
||||
in the `x` direction (left and right) to other micro:bits. This kind
|
||||
of program might be useful in a model car or model rocket.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
@ -39,4 +43,3 @@ basic.forever(() => {
|
||||
### See also
|
||||
|
||||
[receive number](/reference/radio/receive-number), [on data received](/reference/radio/on-data-received)
|
||||
|
||||
|
@ -8,18 +8,17 @@ radio.sendString("Hello!")
|
||||
|
||||
### Parameters
|
||||
|
||||
* `text` is a [String](/reference/types/string) to send by radio.
|
||||
* `msg` is a [string](/reference/types/string) to send by radio.
|
||||
|
||||
### Simulator
|
||||
|
||||
This function only works on the micro:bit, not in browsers.
|
||||
|
||||
|
||||
|
||||
### Example: Two-way radio
|
||||
|
||||
If you load this program onto two or more micro:bits, you can send a code word from one of them to the others by pressing button `A`.
|
||||
The other micro:bits will receive the code word and then show it.
|
||||
If you load this program onto two or more micro:bits, you can send a
|
||||
code word from one of them to the others by pressing button `A`. The
|
||||
other micro:bits will receive the code word and then show it.
|
||||
|
||||
```blocks
|
||||
input.onButtonPressed(Button.A, () => {
|
||||
|
@ -2,10 +2,14 @@
|
||||
|
||||
Send a [string]() and [number]() together by ``radio`` to other micro:bits.
|
||||
|
||||
```sig
|
||||
radio.sendValue("data", 0);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
* a [string](/reference/types/string) to send by radio
|
||||
* a [number](/reference/types/number) to send by radio
|
||||
* ``name`` is a [string](/reference/types/string) to send by radio
|
||||
* ``value`` a [number](/reference/types/number) to send by radio
|
||||
|
||||
### Simulator
|
||||
|
||||
|
@ -10,6 +10,10 @@ function, it will figure out its own group ID by itself. If you load
|
||||
the very same program onto two different micro:bits, they will be able
|
||||
to talk to each other because they will have the same group ID.
|
||||
|
||||
```sig
|
||||
radio.setGroup(0);
|
||||
```
|
||||
|
||||
### Parameters
|
||||
|
||||
* ``id`` is a [number](/reference/types/number) from ``0`` to ``255``.
|
||||
|
@ -8,6 +8,10 @@ The scientific name for the strength of the ``radio`` signal is
|
||||
can be measured as -30 dBm, and a strength of `7` can be
|
||||
measured as +4 dBm.
|
||||
|
||||
```sig
|
||||
radio.setTransmitPower(7);
|
||||
```
|
||||
|
||||
### Range
|
||||
|
||||
If your micro:bit is sending with a strength of `7`, and you are in
|
||||
@ -16,7 +20,7 @@ can reach as far as 70 meters (about 230 feet).
|
||||
|
||||
### Parameters
|
||||
|
||||
* a [number](/reference/types/number) between ``0`` and ``7`` that
|
||||
* ``power`` is a [number](/reference/types/number) between ``0`` and ``7`` that
|
||||
means how strong the signal is.
|
||||
|
||||
### Simulator
|
||||
|
@ -1,16 +1,19 @@
|
||||
# Write Value To Serial
|
||||
|
||||
Writes the full data received data via ``radio`` to serial in JSON format.
|
||||
|
||||
**Note** - This method only works for [send number](/reference/radio/send-number) and [send value](/reference/radio/send-value). It does not work for [send string](/reference/radio/send-string) (although a string can be sent with [send value](/reference/radio/send-value)).
|
||||
|
||||
```sig
|
||||
radio.writeValueToSerial();
|
||||
```
|
||||
|
||||
## Data received format
|
||||
The format for received data printed to serial is as follows
|
||||
- [send number](/reference/radio/send-number) - ```{v:ValueSent,t:MicrobitTimeAlive,s:Unused}```
|
||||
- [send value](/reference/radio/send-number) - ```{v:Value,t:MicrobitTimeAlive,s:Unused,n:"Name"}```
|
||||
- [send string](/reference/radio/send-string) - ```{}``` (currently unavailable)
|
||||
|
||||
|
||||
|
||||
### Simulator
|
||||
|
||||
This function only works on the micro:bit, not in browsers.
|
||||
|
Loading…
Reference in New Issue
Block a user