#include <Adafruit_ILI9341.h>
#include <Adafruit_GFX.h>
#define TFT_CS 5
#define TFT_DC 4
#define TFT_RST -1 // Set to -1 if not using a reset pin
#define SPI_SCK 18 // SCK (Serial Clock)
#define SPI_MISO 19 // MISO (Master In Slave Out)
#define SPI_MOSI 23 // MOSI (Master Out Slave In)
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
void setup() {
Serial.begin(115200);
tft.begin(SPI, SPI_SCK, SPI_MISO, SPI_MOSI);
tft.setRotation(3); // Adjust rotation if needed
tft.fillScreen(ILI9341_BLACK);
// Draw some shapes on the TFT
drawCircle(50, 50, 20, ILI9341_RED);
drawRectangle(100, 50, 30, 40, ILI9341_GREEN);
drawTriangle(180, 50, 160, 90, 200, 90, ILI9341_BLUE);
}
void loop() {
// Your loop code here
}
void drawCircle(int x, int y, int radius, uint16_t color) {
tft.fillCircle(x, y, radius, color);
}
void drawRectangle(int x, int y, int width, int height, uint16_t color) {
tft.fillRect(x, y, width, height, color);
}
void drawTriangle(int x1, int y1, int x2, int y2, int x3, int y3, uint16_t color) {
tft.fillTriangle(x1, y1, x2, y2, x3, y3, color);
}