Hi everyone,
I have this tft st7789 display connected to a arduino nano every:
The pins are connected as follows:
- GND -> ground of arduino
- VCC -> 3.3V
- SCL -> pin 13
- SDA -> pin 11 (COPI)
- RES -> pin 9
- DC -> pin 7
I run a graphics test example from the Adafruit libary and the display works as expected.
Now I want to read images from an SD card and display them on the display. I'm using this SD module:
And I connected it as follows:
GND -> ground of arduino
VCC -> 5V
MISO -> pin 12 (CIPO)
MOSI -> pin 11 (COPI)
SCK -> pin 13
CS -> pin 4
The SD module works also fine in a SD-test example I tried out (not using the tft display).
The problem now arises when I connect everything to the arduino and try to "talk" to both devices.
For example, this setup works fine and the tft display shows "Hello world" on the screen (using the custom testdrawtext() function):
void setup(void) {
Serial.begin(9600);
//pinMode(TFT_CS, OUTPUT);
//digitalWrite(TFT_CS, HIGH);
Serial.print(F("Hello! ST77xx TFT Test"));
// if the display has CS pin try with SPI_MODE0
tft.init(240, 240, SPI_MODE2); // Init ST7789 display 240x240 pixel
tft.fillScreen(ST77XX_BLACK);
// if the screen is flipped, remove this command
tft.setRotation(2);
uint16_t time = millis();
tft.fillScreen(ST77XX_BLACK);
time = millis() - time;
Serial.println(time, DEC);
delay(500);
// large block of text
testdrawtext("Hello World!", ST77XX_WHITE);
delay(1000);
}
But as soon as I add these lines regarding the SD module:
Serial.print("Initializing SD card...");
if (!SD.begin(4)) {
Serial.println("failed!");
}
else {
Serial.println("OK!");
}
the display stays black but the SD card module gets initialized successfully.
I am a beginner regarding arduino in general so I might be not seeing something pretty obvious. There seems to be some communication problem when talking to both devices.
Is there a way to have both devices connected and then specify what device needs to be active a a specific point in time?
I followed a number of different tutorials (e.g. this one https://mytectutor.com/micro-sd-card-module-with-arduino-and-tft-display/ ) but they are either using a ST7735 display which has an additional CS pin which my display does not have (could this be the problem?) or they don't use an SD module.
I'm looking forward to any help I can get on this topic.
Best regards,
Luca