#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
// DEFINE SPI PINS
#define sck 13
#define mosi 11
// Initialize the TFT display
#define TFT_CS 10
#define TFT_DC 9
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// Define the colors for the rainbow
#define TFT_RED 0xF800
#define TFT_ORANGE 0xFD20
#define TFT_YELLOW 0xFFE0
#define TFT_GREEN 0x07E0
#define TFT_BLUE 0x001F
#define TFT_INDIGO 0x481F
#define TFT_VIOLET 0xF81F
// Define the initial diameter of the circle
#define CIRCLE_DIA 200
// Define the number of circles to draw
#define CIRCLE_COUNT 7
void setup() {
// Initialize the TFT display
tft.begin();
tft.setRotation(3); // Adjust the rotation if necessary
// Clear the screen and set the text color to white
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_WHITE);
// Draw the circles in rainbow colors
drawCircles();
// Write diagonally with yellow color and font size 3 by Arvind
writeDiagonally();
}
void loop() {
// Nothing to do here
}
// A function to draw the circles in rainbow colors
void drawCircles() {
// Define an array of colors for the rainbow
uint16_t colors[CIRCLE_COUNT] = {TFT_RED, TFT_ORANGE, TFT_YELLOW, TFT_GREEN, TFT_BLUE, TFT_INDIGO, TFT_VIOLET};
// Define the coordinates of the circle center
int x = tft.width() / 2;
int y = tft.height() / 2;
// Define the initial diameter of the circle
int dia = CIRCLE_DIA;
// Loop through the circle count
for (int i = 0; i < CIRCLE_COUNT; i++) {
// Draw the circle with the corresponding color
tft.fillCircle(x, y, dia / 2, colors[i]);
// Reduce the diameter by 10 pixels
dia -= 25;
}
}
// A function to write diagonally with yellow color and font size 3 by Arvind
void writeDiagonally() {
// Set the text color to yellow
tft.setTextColor(TFT_GREEN);
// Set the text size to 3
tft.setTextSize(2);
// Define the initial coordinates of the text
int x = 40;
int y = 60;
// Define the text to write
char text[] = "by Arvind";
// Loop through the characters of the text
for (int i = 0; i < strlen(text); i++) {
// Write the character at the current position
tft.write(text[i]);
// Move the cursor diagonally by 20 pixels
x += 20;
y += 20;
// Set the cursor to the new position
tft.setCursor(x, y);
}
}