Improve output formatting in examples

This commit is contained in:
Phillip Burgess
2019-01-11 17:05:42 -08:00
parent bdd2756ed1
commit 261e997a90
2 changed files with 38 additions and 41 deletions

View File

@ -25,7 +25,7 @@ DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(9600);
Serial.println("DHTxx test!");
Serial.println(F("DHTxx test!"));
dht.begin();
}
@ -44,7 +44,7 @@ void loop() {
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
@ -53,17 +53,15 @@ void loop() {
// Compute heat index in Celsius (isFahreheit = false)
float hic = dht.computeHeatIndex(t, h, false);
Serial.print("Humidity: ");
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.print(" *C ");
Serial.print(F("°C "));
Serial.print(f);
Serial.print(" *F\t");
Serial.print("Heat index: ");
Serial.print(F("°F Heat index: "));
Serial.print(hic);
Serial.print(" *C ");
Serial.print(F("°C "));
Serial.print(hif);
Serial.println(" *F");
Serial.println(F("°F"));
}