E html>


 
  
#include <Adafruit_GFX.h>    // Include core graphics library
  #include <Adafruit_ILI9341.h> // Include Adafruit_ILI9341 library to drive the display
  
  // 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
  
  // Create display:
  Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
  
  void setup() {
    tft.begin();  // Initialize display
    tft.setRotation(3);  // Adjust display rotation if needed
    tft.fillScreen(ILI9341_BLACK);  // Set background color to black
  }
  
  void loop() {
    // Draw the gradient circle on the display
    drawGradientCircle();
  
    // Delay before refreshing the display
    delay(5000);
  }
  
  void drawGradientCircle() {
    int radius = 100;      // Radius of the circle
    int centerX = 240;    // X-coordinate of the center of the circle
    int centerY = 160;    // Y-coordinate of the center of the circle
    int startColor = tft.color565(255, 0, 0);    // Starting color of the gradient (red)
    int endColor = tft.color565(0, 0, 255);      // Ending color of the gradient (blue)
  
    for (int y = centerY - radius; y <= centerY + radius; y++) {
      for (int x = centerX - radius; x <= centerX + radius; x++) {
        int dx = x - centerX;
        int dy = y - centerY;
  
        // Calculate the distance from the center of the circle
        int distance = sqrt(dx * dx + dy * dy);
  
        // Calculate the color at the current position based on the distance from the center
        int r = map(distance, 0, radius, (startColor >> 11) & 0x1F, (endColor >> 11) & 0x1F);
        int g = map(distance, 0, radius, (startColor >> 5) & 0x3F, (endColor >> 5) & 0x3F);
        int b = map(distance, 0, radius, startColor & 0x1F, endColor & 0x1F);
  
        int color = tft.color565(r, g, b);
  
        // Set the pixel color at the current position
        tft.drawPixel(x, y, color);
      }
    }
  }
  // Define the LED pin
  const int ledPin = 9;  // Replace with the PWM pin connected to the LED
  
  // Set the initial brightness and the rate of change
  int brightness = 0;
  int increment = 5;
  
  void setup() {
    // Set the LED pin as an output
    pinMode(ledPin, OUTPUT);
  }
  
  void loop() {
    // Increase brightness
    while (brightness < 255) {
      analogWrite(ledPin, brightness);
      brightness += increment;
      delay(10);  
    }
  
    // Decrease brightness
    while (brightness > 0) {
      analogWrite(ledPin, brightness);
      brightness -= increment;
      delay(10);  
    }
  }
  

#include <Adafruit_GFX.h>    // Include core graphics library
  #include <Adafruit_ILI9341.h> // Include Adafruit_ILI9341 library to drive the display
  
  // 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
  
  // Create display:
  Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
  
  #include <Fonts/FreeSerif24pt7b.h>  // Add a custom font
  #include <Fonts/FreeSerifBold12pt7b.h>
  
  void setup()  // Start of setup
  {
    // Display setup:
    tft.begin();  // Initialize display
    tft.fillScreen(0x0000);  // Fill screen with black
    tft.setTextWrap(false);  // By default, long lines of text are set to automatically “wrap” back to the leftmost column.
  
    // 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 "DGI AstheticCenter":
    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("DGI AstheticCenter");  // Print a text or value
  
    // Write to the display the text "Yangtshel Wangye":
    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("Yangtshel Wangye");  // 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
  {
    // 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("FA24");  // 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("Drawing:");  // Print a text or value
    // Draw a circle in the box
    for (int16_t i=0; i<60; i+=5) {
      tft.drawCircle(30, 130, i, tft.color565(0, 0, i*4));
    }
  
    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("Words:");  // Print a text or value
    tft.setCursor(10, 200);
    tft.setTextColor(0x07E0, 0x0000);
    tft.println("Hello"); 
  
    // Stop using a custom font
    tft.setFont();  // Reset to standard font, to stop using any custom font previously set
    delay(500);
  
  }  // End of loop
  .jpg)
CIRCLE
  #include <Adafruit_GFX.h>    // Include core graphics library
  #include <Adafruit_ILI9341.h> // Include Adafruit_ILI9341 library to drive the display
  
  // 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
  
  // Create display:
  Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
  
  // Circle position and size variables
  int circleX = 10;
  int circleY = 120;
  int circleSize = 20;
  
  void setup() {
    tft.begin();  // Initialize display
    tft.setRotation(3);  // Adjust display rotation if needed
    tft.fillScreen(ILI9341_BLACK);  // Set background color to black
  }
  
  void loop() {
    // Clear the previous frame
    tft.fillCircle(circleX, circleY, circleSize, ILI9341_BLACK);
  
    // Update circle position
    circleX += 5; // Move the circle 5 pixels to the right
  
    // Check if the circle has reached the right edge of the screen
    if (circleX >= tft.width()) {
      // Reset the circle position to the left edge of the screen
      circleX = 0;
    }
  
    // Draw the circle at the updated position
    tft.fillCircle(circleX, circleY, circleSize, ILI9341_WHITE);
  
    // Delay to control the animation speed
    delay(100);
  }
  BOX
  #include <Adafruit_GFX.h>    // Include core graphics library
  #include <Adafruit_ILI9341.h> // Include Adafruit_ILI9341 library to drive the display
  
  // 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
  
  // Create display:
  Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
  
  // Circle variables
  int circleX = 10;
  int circleY = 120;
  int circleSize = 20;
  int circleSpeed = 5;
  
  // Rectangle variables
  int rectX = 50;
  int rectY = 80;
  int rectWidth = 40;
  int rectHeight = 60;
  int rectSpeed = 3;
  
  void setup() {
    tft.begin();  // Initialize display
    tft.setRotation(3);  // Adjust display rotation if needed
    tft.fillScreen(ILI9341_BLACK);  // Set background color to black
  }
  
  void loop() {
    // Clear the previous frame
    tft.fillCircle(circleX, circleY, circleSize, ILI9341_BLACK);
    tft.fillRect(rectX, rectY, rectWidth, rectHeight, ILI9341_BLACK);
  
    // Update circle position
    circleX += circleSpeed; // Move the circle horizontally
    if (circleX >= tft.width() - circleSize || circleX <= 0) {
      circleSpeed *= -1; // Reverse the direction if the circle reaches the edges
    }
  
    // Update rectangle position
    rectY += rectSpeed; // Move the rectangle vertically
    if (rectY >= tft.height() - rectHeight || rectY <= 0) {
      rectSpeed *= -1; // Reverse the direction if the rectangle reaches the edges
    }
  
    // Draw the updated objects
    tft.fillCircle(circleX, circleY, circleSize, ILI9341_WHITE);
    tft.fillRect(rectX, rectY, rectWidth, rectHeight, ILI9341_GREEN);
  
    // Delay to control the animation speed
    delay(10);
  }
  NIGHT
  #include <Adafruit_GFX.h>    // Include core graphics library
  #include <Adafruit_ILI9341.h> // Include Adafruit_ILI9341 library to drive the display
  
  // 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
  
  // Create display:
  Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
  
  void setup() {
    tft.begin();  // Initialize display
    tft.setRotation(3);  // Adjust display rotation if needed
    tft.fillScreen(ILI9341_BLACK);  // Set background color to black
  }
  
  void loop() {
    // Draw the night-time scene with tree, moon, and stars on the display
    drawNightScene();
  
    // Delay before refreshing the display
    delay(5000);
  }
  
  void drawNightScene() {
    // Set background color to dark blue
  tft.fillScreen(tft.color565(0, 0, 128));
  
    // Draw the moon (circle)
    tft.fillCircle(240, 60, 40, ILI9341_WHITE);
  
    // Draw small stars (white pixels)
    for (int i = 0; i < 100; i++) {
      int x = random(0, tft.width());
      int y = random(0, tft.height());
      tft.drawPixel(x, y, ILI9341_WHITE);
    }
  
    // Draw the tree
    drawTree();
  }
  
  void drawTree() {
    // Draw the trunk (rectangle)
    tft.fillRect(145, 200, 30, 80, tft.color565(101, 67, 33));
  
    // Draw the branches (lines)
    tft.drawLine(160, 200, 130, 150, ILI9341_GREEN);
    tft.drawLine(160, 200, 190, 150, ILI9341_GREEN);
  
    // Draw the foliage (circles)
    tft.fillCircle(160, 150, 40, ILI9341_DARKGREEN);
    tft.fillCircle(140, 170, 40, ILI9341_DARKGREEN);
    tft.fillCircle(180, 170, 40, ILI9341_DARKGREEN);
  }
  
  Draw circle 
  #include <Adafruit_GFX.h>    // Include core graphics library
  #include <Adafruit_ILI9341.h> // Include Adafruit_ILI9341 library to drive the display
  
  // 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
  
  // Create display:
  Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
  
  void setup() {
    tft.begin();  // Initialize display
    tft.setRotation(3);  // Adjust display rotation if needed
    tft.fillScreen(ILI9341_BLACK);  // Set background color to black
  }
  
  void loop() {
    // Draw the gradient circle on the display
    drawGradientCircle();
  
    // Delay before refreshing the display
    delay(5000);
  }
  
  void drawGradientCircle() {
    int radius = 100;      // Radius of the circle
    int centerX = 240;    // X-coordinate of the center of the circle
    int centerY = 160;    // Y-coordinate of the center of the circle
    int startColor = tft.color565(255, 0, 0);    // Starting color of the gradient (red)
    int endColor = tft.color565(0, 0, 255);      // Ending color of the gradient (blue)
  
    for (int y = centerY - radius; y <= centerY + radius; y++) {
      for (int x = centerX - radius; x <= centerX + radius; x++) {
        int dx = x - centerX;
        int dy = y - centerY;
  
        // Calculate the distance from the center of the circle
        int distance = sqrt(dx * dx + dy * dy);
  
        // Calculate the color at the current position based on the distance from the center
        int r = map(distance, 0, radius, (startColor >> 11) & 0x1F, (endColor >> 11) & 0x1F);
        int g = map(distance, 0, radius, (startColor >> 5) & 0x3F, (endColor >> 5) & 0x3F);
        int b = map(distance, 0, radius, startColor & 0x1F, endColor & 0x1F);
  
        int color = tft.color565(r, g, b);
  
        // Set the pixel color at the current position
        tft.drawPixel(x, y, color);
      }
    }
  }
  