Hi, I am struggling with a simple TFT display + SD card reader setup.
I am using a 1.47 inch LCD display from Waveshare and the standard SD card reader module. I tested the display with the test sketch and everything worked fine. Then I connected the SD card reader and the problem started. I can connect to the module and read files - no problem, but I can no longer update the TFT screen. I shortened the code to the absolute minimum (see below). After (!SD.begin(SD_CS)) interaction with the display is no longer possible. I tried setting the CS pins manually, but that had no effect. In another thread I read that the SD card module is quite power hungry, so I removed the USB connector and connected the breadboard to my power supply, but the problem persists.
I'm happy about any tip!
Arduino Uno (the old DIP version)
#include <Adafruit_GFX.h>
#include <Adafruit_ST7789.h>
#include <SPI.h>
#include <SD.h>
// For the breakout board, you can use any 2 or 3 pins.
// These pins will also work for the 1.8" TFT shield.
#define TFT_CS 10
#define TFT_RST 8 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 7
// OPTION 2 lets you interface the display using ANY TWO or THREE PINS,
// tradeoff being that performance is not as fast as hardware SPI above.
#define TFT_MOSI 11 // Data out
#define TFT_SCLK 13 // Clock out
// OR for the ST7789-based displays, we will use this call
Adafruit_ST7789 tft = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST);
#define SD_CS 4 // Chip select line for SD card
void setup() {
Serial.begin(115200);
Serial.print(F("Hello! ST77xx TFT Test"));
Serial.println(F("Initialized"));
tft.init(172, 320);
// MY CODE
tft.fillScreen(ST77XX_WHITE); // works
tft.drawPixel(100, 105, ST77XX_BLUE); // works
Serial.print("Initializing SD card...");
if (!SD.begin(SD_CS)) {
Serial.println("failed!");
return;
}
Serial.println("SD card is connected!"); // works
// digitalWrite(4, HIGH);
// digitalWrite(4, LOW);
// digitalWrite(10, HIGH);
// digitalWrite(10, LOW);
tft.fillScreen(ST77XX_ORANGE); // display remains white...
}
UPDATE: added more info to the code snippet.