#include "SPI.h"
#include "Adafruit_GFX.h"
// #include "Adafruit_ILI9341.h"
#include "Adafruit_ST7735.h"
//connections
//Display: ESP32-C3 - refer schematice-https://docs.espressif.com/projects/esp-idf/en/v5.2/esp32c3/_images/esp32-c3-devkitm-1-v1-pinout.png
// or pg 11 of datasheet-https://www.espressif.com/sites/default/files/documentation/esp32-c3-mini-1_datasheet_en.pdf
// 3.3V : VCC(3V3)
// GND : GND
// CS : 10 >>>chip enable pin (FSPICS0)
// RST : 9 >>>RST/RES- Reset pin can be connected to RST Pin of esp but connecting to a GPIO pin is better as display can be reset via program
// D/C : 8 >>>Data/command pin
// MOSI : 7 >>>SPI data (MCU → LCD) (FSPID)
// SCK : 6 >>>SPI clock (FSPICLK)
// LED : 5V >>>backlight
// MISO : 2 >>>SPI data (LCD → MCU) (FSPIQ)
//NOTE: Reset is not simulated in wokwi
//Pin definition
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
#define TFT_MOSI 7
#define TFT_SCLK 6
//creating a display object named "tft"- TFT_CS and TFT_DC are the parameters passed to the constructor
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS,TFT_DC,TFT_RST);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.printf("HelloWorld\n");
tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab
tft.fillScreen(ST7735_RED);
delay(1000);
Serial.printf("HelloWorld\n");
//display code- same as done in arduino case
tft.setCursor(0,0);
tft.setTextColor(ST7735_WHITE);
tft.println("Hello!");
Serial.printf("HelloWorld\n");
tft.fillScreen(ST7735_GREEN);
delay(1000);
tft.fillScreen(ST7735_BLUE);
delay(1000);
tft.fillScreen(ST7735_BLACK);
delay(1000);
tft.setCursor(2, 2);
tft.setTextColor(ST7735_RED);
tft.println("WORLD");
}
void loop() {
// put your main code here, to run repeatedly:
}
Loading
esp32-c3-devkitm-1
esp32-c3-devkitm-1