-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from navalog/main
Example TemperatureHumidityMatrix
- Loading branch information
Showing
1 changed file
with
48 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
examples/TemperatureHumidityMatrix/TemperatureHumidityMatrix.ino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "Modulino.h" | ||
#include "ArduinoGraphics.h" | ||
#include "Arduino_LED_Matrix.h" | ||
|
||
ModulinoThermo thermo; | ||
ArduinoLEDMatrix matrix; | ||
|
||
float temperature = -273.15; | ||
float humidity = 0.0; | ||
|
||
void setup() { | ||
Serial.begin(9600); | ||
|
||
Modulino.begin(); | ||
thermo.begin(); | ||
|
||
matrix.begin(); | ||
delay(100); | ||
} | ||
|
||
void loop() { | ||
//Acquire temperature and humidity | ||
temperature = thermo.getTemperature(); | ||
humidity = thermo.getHumidity(); | ||
|
||
//Convert the temperature float to a string with 1 decimal point shown | ||
//and add °C at the end | ||
String temperature_text = String(temperature, 1) + "°C"; | ||
|
||
//Convert the humidity float to a string with no decimal points shown | ||
//and add % at the end | ||
String humidity_text = String(humidity, 0) + "%"; | ||
|
||
//Print each of the sensor values on serial | ||
Serial.print(temperature_text + " "); | ||
Serial.println(humidity_text); | ||
|
||
//Show on the UNO R4 WiFi LED matrix the data | ||
|
||
matrix.beginDraw(); | ||
matrix.stroke(0xFFFFFFFF); | ||
matrix.textScrollSpeed(75); | ||
matrix.textFont(Font_5x7); | ||
matrix.beginText(0, 1, 0xFFFFFF); | ||
matrix.println(" " + temperature_text + " " + humidity_text + " "); | ||
matrix.endText(SCROLL_LEFT); | ||
matrix.endDraw(); | ||
} |