/*
Simple "Hello World" for ILI9341 LCD
https://wokwi.com/arduino/projects/308024602434470466
*/
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
// 2.8" TFT display with ILI9341, 240x320
// Display | color | ESP32 pin (38 pins Dev)
// GND | black | GND
// VCC | red | 3.3V
// SCK | blue | GPIO18 -- CLK
// SDA | green | GPIO23 -- MOSI
// RST | - | -
// D/C | gelb | GPIO22 (data/command toggle, for displays, not SPI standard)
// CS | orange | GPIO5 SS (chip select)
#define TFT_DC 22 // GPIO 22, beliebig.. Display Data/command
#define TFT_CS 5 // Chip select
// TODO: backlight == LED mit PWM...
#define TFT_MOSI 23
#define TFT_CLK 18
//#define TFT_RST
// #define TFT_MISO -- not used...
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
// If using the breakout, change pins as desired
// Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK);
/*
void setRotation(uint8_t r);
void invertDisplay(bool i);
void scrollTo(uint16_t y);
*/
void setup() {
tft.begin();
tft.setCursor(26, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println("Hello, TFT!");
tft.setCursor(20, 160);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("I can has colors?");
// Meme reference: https://english.stackexchange.com/questions/20356/origin-of-i-can-haz
}
/* void loop() { } */
void loop() {
for (int i = 0; i<30; i=i+5) {
//tft.clearDisplay();
tft.setCursor(26+i, 120+i);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println("Hello, TFT!");
tft.setCursor(20+i, 160+i);
tft.setTextColor(ILI9341_GREEN);
tft.setTextSize(2);
tft.println("I can has colors?");
delay(1000);
}
}my Display has a different pinout.
this is just to simulate..
// 2.8" TFT display with ILI9341, 240x320
// Display | color | ESP32 pin (38 pins Dev)
// GND | black | GND
// VCC | red | 3.3V
// SCK | blue | GPIO18
// SDA | green | GPIO21 incorrect? --> MOSI GPIO23
// RST | - | -
// D/C | gelb | GPIO22 (data/command toggle, for displays, not SPI standard)
// CS | orange | GPIO5 SS (chip select)