#include <Adafruit_ILI9341.h>
#include <SPI.h>
// Define SPI pins for RP2040 Pico
#define TFT_CS 17 // Chip select control pin (GP17)
#define TFT_DC 16 // Data Command control pin (GP16)
#define TFT_RST 21 // Reset pin (can be connected or left unused) (GP18)
#define TFT_MOSI 19 // SPI MOSI (GP19)
#define TFT_SCLK 18 // SPI Clock (GP18)
#define TFT_MISO 20 // SPI MISO (not used by the display) (GP20)
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_CS);
#define WIDTH 320
#define HEIGHT 240
void setup(void) {
// Initialize the display
tft.begin();
tft.setRotation(1);
}
void loop() {
float scale[9];
for (byte i = 0; i < 9; i++)
scale[i] = (float)rand() / RAND_MAX / 4;
for (int y = 0; y < HEIGHT; y++) {
float ySin1 = sin(y * scale[1]);
float ySin5 = sin(y * scale[5]);
float yScaled2 = y * scale[2];
for (int x = 0; x < WIDTH; x++) {
float xScaled0 = x * scale[0];
float xScaled3 = x * scale[3];
float xyScaled4 = (x + y) * scale[4];
uint8_t r = 15.5 + 15.5 * sin(xScaled0 + ySin1);
uint8_t g = 31.5 + 31.5 * cos(yScaled2 + sin(xScaled3));
uint8_t b = 15.5 + 15.5 * sin(xyScaled4 + ySin5);
uint16_t rgb565 = b | (g << 5) | (r << 11);
tft.drawPixel(x, y, rgb565);
}
}
// Set the text color to yellow
tft.setTextColor(ILI9341_YELLOW);
// Set the text size to 2 (adjust as needed)
tft.setTextSize(2);
// Set the cursor position (adjust as needed)
tft.setCursor(10, 210);
// Print the text "By Arvind"
tft.print("By Arvind");
}