// #include "SPI.h"
// #include "Adafruit_GFX.h"
// #include <Adafruit_ST7735.h>
#include "User_Setup.h"
#include <TFT_eSPI.h> // Graphics and font library for ST7735 driver chip
TFT_eSPI tft = TFT_eSPI(); // Invoke library, pins defined in User_Setup.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.init();
// tft.begin(); //begining the display
// pinMode(TFT_RST,OUTPUT); //Reset pin set as output
// //display code- same as done in arduino case
// tft.setCursor(10,0);
// tft.setTextColor(ILI9341_WHITE);
// tft.setTextSize(3);
// tft.println("Hello!");
// tft.setCursor(90, 160);
// tft.setTextColor(ILI9341_BLUE);
// tft.setTextSize(2);
// tft.println("Hello");
// tft.setCursor(90, 180);
// tft.setTextColor(ILI9341_RED);
// tft.println("WORLD");
}
void loop() {
// put your main code here, to run repeatedly:
//display code- same as done in arduino case
// tft.setCursor(10,0);
// tft.setTextColor(TFT_WHITE);
// tft.setTextSize(3);
// tft.print("Hello!");
// tft.setCursor(90, 160);
// tft.setTextColor(TFT_BLUE);
// tft.setTextSize(2);
// tft.print("Hello");
// tft.setCursor(90, 180);
// tft.setTextColor(TFT_RED);
// tft.print("WORLD");
tft.fillScreen(TFT_RED);
Serial.printf("Red %d %d\n", TFT_RED, TFT_RED);
delay(1000);
tft.fillScreen(TFT_GREEN);
delay(1000);
tft.fillScreen(TFT_BLUE);
delay(1000);
tft.fillScreen(TFT_BLACK);
delay(1000);
tft.fillScreen(TFT_WHITE);
delay(1000);
tft.fillScreen(random(0x10000));
delay(1000);
}
Loading
esp32-c3-devkitm-1
esp32-c3-devkitm-1