#include // Core graphics library #include "SWTFT.h" // Hardware-specific library #include dht11 DHT; #define DHT11_PIN 17 #define BLACK 0x0000 #define BLUE 0x001F #define RED 0xF800 #define GREEN 0x07E0 #define CYAN 0x07FF #define MAGENTA 0xF81F #define YELLOW 0xFFE0 #define WHITE 0xFFFF SWTFT tft; int chk; void setup(void) { Serial.begin(9600); Serial.println(F("TFT LCD test")); tft.reset(); uint16_t identifier = tft.readID(); Serial.print(F("LCD driver chip: ")); Serial.println(identifier, HEX); tft.begin(identifier); Serial.println(F("Benchmark Time (microseconds)")); Serial.print(F("Screen fill")); delay(500); Serial.println(F("Done!")); } void loop(void) { chk = DHT.read(DHT11_PIN); // READ DATA Serial.print(DHT.humidity,1); Serial.print(",\t"); Serial.println(DHT.temperature,1); tft.fillScreen(BLACK); tft.setCursor(10, 10); if (DHT.temperature > 30){ tft.setTextColor(RED); }else if (DHT.temperature > 27 || DHT.temperature < 30) { tft.setTextColor(YELLOW); } else if(DHT.temperature < 27 || DHT.temperature > 10){ tft.setTextColor(BLUE); } else if (DHT.temperature <10){ tft.setTextColor(CYAN); } else { tft.setTextColor(GREEN); } tft.setTextSize(5); String stringOne = ("Temp "); String stringThree = stringOne + DHT.temperature; tft.println(stringThree); tft.setTextColor(WHITE); tft.setCursor(10, 60); String stringTwo = "Hum %"; String stringFour = stringTwo + DHT.humidity; tft.println(stringFour); delay(5000); }