#include <Adafruit_ILI9341.h>
#include <Adafruit_GFX.h>
//#include <spi>
#define TFT_CS 8
#define TFT_DC 3
#define TFT_RST 4
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 240
#define SPI_MOSI 11 // Master Out Slave In
#define SPI_MISO 9 // Master In Slave Out (not used in many displays)
#define SPI_SCK 13 // Serial Clock
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
const int rhombusSize = 10; // Length of rhombus side; Changeable, preferably 95 to 115
const int numberOfRhombuses = 30; // Changeable, preferably 16 to 22
void drawRainbowRhombus(int x, int y, int size) {
for (int i = 0; i < 6; ++i) {
uint8_t hue = i * 255 / 6; // Rainbow gradient
uint16_t color = tft.color565(hue, 255, 255);
tft.fillRoundRect(x, y, size, size, 10, color);
x += size;
y += size;
tft.fillRoundRect(x, y, size, size, 10, color);
x -= size;
y += size;
}
}
void setup() {
tft.begin();
// Adjust rotation: 0 for default, 1 for 90 degrees, 2 for 180 degrees, 3 for 270 degrees
tft.setRotation(3);
tft.fillScreen(ILI9341_BLACK);
for (int i = 0; i < numberOfRhombuses; ++i) {
// Calculate position based on polar coordinates
int x = SCREEN_WIDTH / 2 - rhombusSize / 2 + static_cast<int>(50 * cos((1 + i) * 2 * PI / numberOfRhombuses));
int y = SCREEN_HEIGHT / 2 - rhombusSize / 2 + static_cast<int>(50 * sin((1 + i) * 2 * PI / numberOfRhombuses));
drawRainbowRhombus(x, y, rhombusSize);
}
// Optionally, add a title text to the display
tft.setCursor(10, 10);
tft.setTextColor(ILI9341_YELLOW);
tft.setTextSize(2);
tft.print(F(" CODE BY ARVIND "));
}
void loop() {
// Your loop code here
}
Loading
wemos-s2-mini
wemos-s2-mini