I am working with Adafruit’s SSD 1351 OLED display, which works just fine with this library https://github.com/pkourany/Adafruit_SSD1351_Library. In addition, the SD card of this display works as well, when using the SD-Card-Library on the web IDE. However, if I want to use display and SD card simultaneously, writing on the SD card does not work any more. As soon as initialize the display with tft.begin();, no data is written on the SD card. Writing data on the SD card works fine, as long as the display is not initialized. Code was complied and flashed with web IDE without any problems.
Any ideas what could be wrong?
Here is my code;
#include "application.h"
#include "sd-card-library/sd-card-library.h"
#include "Adafruit_mfGFX.h"
#include "Adafruit_SSD1351.h"
File myFile;
#define sclk A3 //2
#define mosi A5 //3
#define dc D3 //4
#define cs A2 //5
#define rst D2 //6
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF
const uint8_t chipSelect = A1;
const uint8_t mosiPin = A5;
const uint8_t misoPin = A4;
const uint8_t clockPin = A3;
Adafruit_SSD1351 tft = Adafruit_SSD1351(cs, dc, rst);
void initializeSDCard(){
// TFTDisplay.text("Initializing SD card...", 0, 70);
tft.println("Initializing SD card...");
if(! SD.begin(mosiPin, misoPin, clockPin, chipSelect)){
// TFTDisplay.text("Card failed, or not present", 0, 80);
tft.println("Card failed, or not present");
}
else{
// TFTDisplay.text("card initialized",0,80);
tft.println("Card initialized");
}
delay(500);
tft.fillScreen(BLACK);
}
void setup()
{
tft.begin();
delay(500);
initializeSDCard();
int fsr1 = analogRead(A0);
File dataFile = SD.open("data21.txt", FILE_WRITE);
dataFile.println(fsr1);
dataFile.close();
tft.println("Hello World!");
delay(500);
tft.fillScreen(BLACK);
}
void loop()
{
}