#include // Include core graphics library #include // Include Adafruit_ILI9341 library to drive the display #include DFRobot_DHT11 DHT; #define DHT11_PIN 3 // Declare pins for the display: #define TFT_DC 2 #define TFT_RST 0 // You can also connect this to the Arduino reset in which case, set this #define pin to -1! #define TFT_CS 1 // The rest of the pins are pre-selected as the default hardware SPI for Arduino Uno (SCK = 13 and SDA = 11) // Create display: Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST); #include // Add a custom font #include int Variable1; // Create a variable to have something dynamic to show on the display void setup() // Start of setup { // Display setup: tft.begin(); // Initialize display tft.fillScreen(0x0000); // Fill screen with black //tft.setRotation(0); // Set orientation of the display. Values are from 0 to 3. If not declared, orientation would be 0, // which is portrait mode. tft.setTextWrap(false); // By default, long lines of text are set to automatically “wrap” back to the leftmost column. // To override this behavior (so text will run off the right side of the display - useful for // scrolling marquee effects), use setTextWrap(false). The normal wrapping behavior is restored // with setTextWrap(true). // Write to the display the text "Hello": tft.setCursor(0, 0); // Set position (x,y) tft.setTextColor(0xFFFF); // Set color of text. First is the color of text and after is color of background tft.setTextSize(4); // Set text size. Goes from 0 (the smallest) to 20 (very big) tft.println("Hello"); // Print a text or value // Start using a custom font: tft.setFont(&FreeSerif24pt7b); // Set a custom font tft.setTextSize(0); // Set text size. We are using custom font so you should always set text size as 0 // Write to the display the text "World": tft.setCursor(0, 80); // Set position (x,y) tft.setTextColor(0xF800); // Set color of text. We are using custom font so there is no background color supported tft.println("World!"); // Print a text or value // Write to the display the text "Fablab Kamakura": tft.setFont(&FreeSerifBold12pt7b); tft.setTextSize(0); tft.setCursor(10, 270); // Set position (x,y) tft.setTextColor(0x07E0); // Set color of text. We are using custom font so there is no background color supported tft.println("Fablab Kamakura"); // Print a text or value // Write to the display the text "Setyawan UGM": tft.setCursor(10, 301); // Set position (x,y) tft.setTextColor(0x07FF); // Set color of text. We are using custom font so there is no background color supported tft.println("Setyawan UGM"); // Print a text or value // Stop using a custom font tft.setFont(); // Reset to standard font, to stop using any custom font previously set tft.drawRoundRect(3, 95, 230, 60, 10, 0x07FF); // Draw rounded rectangle (x,y,width,height,radius,color) tft.drawRoundRect(3, 165, 230, 60, 10, 0x07FF); // It draws from the location to down-right tft.drawRoundRect(140, 5, 100, 50, 10, 0x07FF); } // End of setup void loop() // Start of loop { DHT.read(DHT11_PIN); // Write to the display the Variable1 with left text alignment: tft.setCursor(155, 20); // Set position (x,y) tft.setTextColor(0x001F, 0x0000); // Set color of text. First is the color of text and after is color of background tft.setTextSize(3); // Set text size. Goes from 0 (the smallest) to 20 (very big) tft.println("FA22"); // Print a text or value tft.setCursor(10, 105); // Set position (x,y) tft.setTextColor(0xFFE0, 0x0000); // Set color of text. First is the color of text and after is color of background tft.setTextSize(2); // Set text size. Goes from 0 (the smallest) to 20 (very big) tft.println("Temperature:"); // Print a text or value tft.setCursor(10, 130); tft.setTextColor(0x07E0, 0x0000); tft.println("("); tft.setCursor(20, 130); tft.println((char)247); // Print a text or value of symbol degree with char247 tft.setCursor(35, 130); tft.println("C)"); tft.setCursor(10, 175); // Set position (x,y) tft.setTextColor(0xFFE0, 0x0000); // Set color of text. First is the color of text and after is color of background tft.setTextSize(2); // Set text size. Goes from 0 (the smallest) to 20 (very big) tft.println("Humadity:"); // Print a text or value tft.setCursor(10, 200); tft.setTextColor(0x07E0, 0x0000); tft.println("(%)"); tft.setCursor(165, 107); // Set position (x,y) tft.setTextColor(0xF81F, 0x0000); // Set color of text. First is the color of text and after is color of background tft.setTextSize(5); // Set text size. Goes from 0 (the smallest) to 20 (very big) tft.println(DHT.temperature); // Print a text or value tft.setCursor(165, 177); // Set position (x,y) tft.setTextColor(0xF81F, 0x0000); // Set color of text. First is the color of text and after is color of background tft.setTextSize(5); // Set text size. Goes from 0 (the smallest) to 20 (very big) tft.println(DHT.humidity); // Print a text or value // Stop using a custom font tft.setFont(); // Reset to standard font, to stop using any custom font previously set delay(500); } // End of loop