Ordered a TFT some time ago and now I’m trying to make a battery capacity data logger with the TFT and an SD card. I know there are modules which integrate the two, but I’m working with what I’ve got.
Hardware constructor Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_MISO, TFT_RST) does not work.
The screen works initially with software constructor Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_MISO, TFT_MOSI, TFT_SCLK, TFT_RST), but then does not work after the SD card initializes (successful or not).
What am I missing?
//#include <Adafruit_GFX.h>
#include <Adafruit_ST7735.h>
#include <SPI.h>
#include <SD.h>
// 1.77" ST7735 TFT
#define TFT_RST 10 // Use -1 if tied to arduino reset pin
#define TFT_CS 9 // User definable
#define TFT_MOSI 11 // Hardware permanent
#define TFT_MISO 12 // User definable
#define TFT_SCLK 13 // Hardware permanent
// SD Card
#define SD_CS 8 // User definable
#define SD_MOSI 11 // Hardware permanent
#define SD_MISO 12 // User definable
#define SD_SCLK 13 // Hardware permanent
// Hardware SPI Constructor for ST7735
// Does not work
Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_MISO, TFT_RST);
// Software SPI Constructor for ST7735
// Works
//Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_MISO, TFT_MOSI, TFT_SCLK, TFT_RST);
void setup(){
Serial.begin(9600);
while(!Serial){;} // wait for serial port to connect
tft.initR(INITR_BLACKTAB);
tft.fillScreen(ST7735_BLACK);
tft.setRotation(1);
tft.setTextSize(0); // Height = 7 pixels
tft.setCursor(0,0);
tft.println("Initializing SD Card...");
if(!SD.begin(SD_CS)){
Serial.println("failed!");
}
else{
Serial.println("OK!");
}
// below lines do not execute
tft.fillScreen(ST7735_BLACK);
tft.setCursor(0,8);
tft.println("line 2");
}
void loop(){
}