Hello, I have a 2.8 Inch TFT LCD, resolution 320x240, ILI9341 Controller, SPI Interface, I have connected it to my arduino, now I have added an RC522 RFID reader and when reading a card the screen goes blank, if anyone Can you help me I would appreciate it, thank you
Based on what you've written so far, you could have a problem with your sketch, or your wiring, or your power supply. You might even have faulty hardware.
Please take some time and read How to get the best out of this forum and then provide the information necessary for people to be able to assist you with your problem.
Separately everything works fine, I have the power through the Arduino, the problem is when I scan a card and tell it to show on the screen the screen stays blank or flashes
You forgot to mention which one.
OK
You might be running out of memory but nobody will be able to analyse that if you don't post your complete code. Adafruit libraries often use dynamic memory allocation which is not counted in the memory usage reported by the IDE but we don't know if you're using an Adafruit library or not.
Hello, it is an Arduino mega, I attach the code that I used:
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <SPI.h>
#include <MFRC522.h>
#define TFT_CS 10
#define TFT_RST 8
#define TFT_DC 9
#define RFID_SS 53
#define RFID_RST 7
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
MFRC522 rfid(RFID_SS, RFID_RST);
void setup() {
Serial.begin(9600);
Serial.println("Inicializando pantalla TFT...");
tft.begin();
tft.setRotation(2);
tft.fillScreen(ILI9341_BLACK);
tft.setTextSize(2);
tft.setTextColor(ILI9341_WHITE);
tft.setCursor(10, 120);
tft.print("Escanee una tarjeta");
Serial.println("Pantalla TFT inicializada.");
Serial.println("Inicializando módulo RFID...");
SPI.begin();
rfid.PCD_Init();
Serial.println("Módulo RFID inicializado.");
}
void loop() {
Serial.println("Esperando tarjeta RFID...");
if (!rfid.PICC_IsNewCardPresent()) {
return;
}
if (!rfid.PICC_ReadCardSerial()) {
return;
}
Serial.println("Tarjeta detectada.");
digitalWrite(TFT_CS, LOW);
tft.fillScreen(ILI9341_BLACK);
tft.setCursor(10, 120);
tft.print("Tarjeta detectada:");
String uidString;
for (byte i = 0; i < rfid.uid.size; i++) {
uidString += String(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");
uidString += String(rfid.uid.uidByte[i], HEX);
}
uidString.toUpperCase();
tft.setCursor(10, 150);
tft.print(uidString);
digitalWrite(TFT_CS, HIGH);
Serial.print("UID de la tarjeta: ");
Serial.println(uidString);
delay(1000);
}
Unfortunately I have no idea what goes wrong.