Home ArduinoArduino Code Display temperature on Arduino Esplora LCD

Display temperature on Arduino Esplora LCD

This example will read the temperature using the built in temperature sensor on the Arduino Esplora and display it on the LCD

esplora

esplora

Code

 

[codesyntax lang=”cpp”]

#include <Esplora.h>
#include <TFT.h>
#include <SPI.h>

char tempCelsius[3];
char tempFahrenheit[3];

void setup()
{
//setup the LCD
EsploraTFT.begin();
EsploraTFT.background(0,0,0); 
EsploraTFT.stroke(255,255,255);
EsploraTFT.setTextSize(2);
EsploraTFT.text("Temperature",0,0);

}

void loop()
{
// read the temperature sensor in Celsius, then Fahrenheit:
String celsius = String(Esplora.readTemperature(DEGREES_C));
String fahrenheit = String(Esplora.readTemperature(DEGREES_F));
celsius.toCharArray(tempCelsius, 3);
fahrenheit.toCharArray(tempFahrenheit, 3);
EsploraTFT.stroke(255,255,255);
EsploraTFT.text(tempCelsius, 0, 30);
EsploraTFT.text(tempFahrenheit, 0, 60);
// wait a second before reading again:
delay(1000);
EsploraTFT.stroke(0,0,0);
EsploraTFT.text(tempCelsius, 0, 30);
EsploraTFT.text(tempFahrenheit, 0, 60);
}

[/codesyntax]

 

Links
Atmega32U4 Esplora Game Board Module Leonardo Updated Version FZ0606 Free Shipping

1.8 inch TFT LCD For Arduino Esplora

You may also like