2017-06-21 20:17:25 +02:00
# Connect
2017-12-01 23:57:34 +01:00
Use the radio to send the current moisture level to a dashboard @boardname @. The dashboard will display one LED per @boardname @.
2017-06-21 20:17:25 +02:00
## Moisture sensor
2017-12-01 23:57:34 +01:00
To make it happen, we need to change the program to:
2017-06-21 20:17:25 +02:00
* setup the radio by choosing group 4 and sending the serial number of the device
2017-12-01 23:57:34 +01:00
* send the moisture level **divided by 4** as the dashboard takes values between ``0`` and ``255``.
2017-06-21 20:17:25 +02:00
```blocks
radio.setTransmitSerialNumber(true)
radio.setGroup(4)
led.setBrightness(64)
let reading = 0
basic.forever(() => {
pins.analogWritePin(AnalogPin.P1, 1023)
reading = pins.analogReadPin(AnalogPin.P0)
radio.sendNumber(reading / 4);
pins.analogWritePin(AnalogPin.P1, 0)
led.plotBarGraph(
reading,
1023
)
if (input.buttonIsPressed(Button.A)) {
basic.showNumber(reading)
}
basic.pause(5000);
})
```
## The dashboard
2017-12-01 23:57:34 +01:00
The dashboard code is found in the [radio dashboard ](/examples/radio-dashboard ) example.
2017-06-21 20:17:25 +02:00
2017-12-01 23:57:34 +01:00
### Setup a dashboard @boardname@
2017-06-21 20:17:25 +02:00
2017-12-01 23:57:34 +01:00
Download the code from that example into the @boardname @ that will be used to display the results.
2017-06-21 20:17:25 +02:00
2017-12-01 23:57:34 +01:00
### Dashboard operation
2017-06-21 20:17:25 +02:00
2017-12-01 23:57:34 +01:00
When the dashboard receives a message from a @boardname @, it finds a pixel to use for that board (and remembers it). The number sent in the messages from the board are used to set the brightness of the LED.
When a message hasn't been received by the dashboard for awhile, it's pixel will start to blink. Then, after some time, it will simply turn off.
2017-06-21 20:17:25 +02:00
```package
radio
```