I've been trying to get my LCD to work for hours, checking wiring, checking code, making small changes, etc. but nothing is working. When I plug in the ESP32 that I'm using (ESP32-S3, Amazon.com: MusRock ESP32-S3-N16R8 Na IoT Development Board with Wi- Fi + BLE, Pre-Soldered AI Module : Electronics), the LCD turns on and stays blank white no matter what code I feed into it. (And my keypad won't read the bottom row for some reason)
Here's the code I have so far:
#include <Keypad.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
// SINGLE PINOUT
#define LED_PIN 4
#define SERVO 5
#define BUZZER 6
#define DEFUSE 7
#define TOGGLE_1 15
#define TOGGLE_2 16
// LCD PINOUT
#define LCD_CS 10
#define LCD_DC 9
#define LCD_RST 18
// RC522 PINOUT
#define RC522_CS 14
#define RC522_RST 8
// KEYPAD PINOUT
#define R1 45
#define R2 46
#define R3 21
#define R4 37
#define C1 38
#define C2 39
#define C3 41
#define C4 42
// SHARED
#define SPI_MOSI 11
#define SPI_SCK 12
#define SPI_MISO 13
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}};
byte rowPins[ROWS] = {R1, R2, R3, R4};
byte colPins[COLS] = {C1, C2, C3, C4};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
String input = "";
Adafruit_ILI9341 tft(LCD_CS, LCD_DC, LCD_RST);
void setup() {
Serial.begin(115200);
delay(1000);
Serial.println("BOOT");
pinMode(LCD_RST, OUTPUT);
digitalWrite(LCD_RST, LOW);
delay(100);
digitalWrite(LCD_RST, HIGH);
delay(200);
tft.begin();
tft.setRotation(1);
tft.fillScreen(ILI9341_RED);
Serial.println("DISPLAY OK");
}
void loop() {
char key = keypad.getKey();
if (key) {
readKeypad(key);
updateDisplay();
delay(100);
}
}
void readKeypad(char key) {
switch(key) {
case '#':
input = "";
break;
case '*':
break;
default:
input += key;
break;
}
}
void updateDisplay() {
tft.fillScreen(ILI9341_BLACK);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(2);
tft.setCursor(20, 20);
tft.print(input);
Serial.println(input);
}