Now that we know how to read the environment parameters, we can implement the application logic to control other peripherals according to the values acquired. As described in the previous sections, the Android Things monitoring app uses the temperature and pressure to controls two devices:
- An RGB LED that shows the current pressure state
- A RED LED that shows if the temperature is lower than a threshold
To make the app work, we have to fix the pressure threshold values. To simplify the development process we can suppose that there are two thresholds:
- Threshold one, that we will call
LEVEL_1
, is 1022.9 mb - Threshold two, that we will call
LEVEL_2
, is 1009.14 mb
The app logic that we will implement works in this way:
- If the current pressure is over the
LEVEL_1
then the RGB LED will have the green and red color turned on (yellow) - If the current pressure is between
LEVEL_1
andLEVEL_2
the RGB LED will have only the green color turned on - If the current pressure is below
LEVEL_2
...