TFT loading from built-in SD Card problems

I’m trying to use a 1.8" ST7735 w/ SD card slot and Arduino UNO to load and display a .bmp file (just one for now). I formatted the 8 GB microSD as MS-DOS FAT. I keep getting this error:

In file included from /private/var/folders/th/yhd_876n1cv3y157bc7312s80000gn/T/AppTranslocation/41E15F2B-DA9E-4CAA-94E4-1210606246BE/d/Arduino.app/Contents/Java/libraries/TFT/src/TFT.h:36:0,
from /Users/…/Documents/Arduino/SD_Disp/SD_Disp.ino:3:
/private/var/folders/th/yhd_876n1cv3y157bc7312s80000gn/T/AppTranslocation/41E15F2B-DA9E-4CAA-94E4-1210606246BE/d/Arduino.app/Contents/Java/libraries/TFT/src/utility/Adafruit_GFX.h: In static member function ‘static PImage PImage::loadImage(const char*)’:
/private/var/folders/th/yhd_876n1cv3y157bc7312s80000gn/T/AppTranslocation/41E15F2B-DA9E-4CAA-94E4-1210606246BE/d/Arduino.app/Contents/Java/libraries/TFT/src/utility/Adafruit_GFX.h:318:40: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]
if ((bmpFile = SD.open(fileName)) == NULL) {
^

and when I run it (since those are warnings), the program is unable to load the image.

Here’s the code:

#include <SD.h>
#include <SPI.h>
#include <TFT.h>

#define SD_MOSI           11
#define TFT_SDA           11
#define SD_MISO           12
#define SD_SCK            13
#define TFT_SCK           13
#define SD_CS             4
#define TFT_CS            10
#define TFT_DC            8
#define TFT_RST           9

TFT tft = TFT(TFT_CS, TFT_DC, TFT_RST);
PImage bmp;

void setup() {
  Serial.begin(9600);
  tft.begin();
  tft.background(255,255,255);
  if (!SD.begin(SD_CS)) {
    Serial.print("failed");
    return;
  }

  bmp = tft.loadImage("Words1.bmp");
  if (!bmp.isValid()) {
    Serial.println("error while loading image");
  }

}
void loop() {
  // put your main code here, to run repeatedly:
    tft.image(bmp,0,0);
    delay(2000);
}

Any help would be appreciated. I’ve looked at lots of similar discussions and can’t seem to find any that help. Lmk if there’s any information I’ve omitted or if a picture of my wiring would help - but I’m pretty sure I’ve got it wired correctly. There are no issues when I use the display without the SD card to draw text.

I built your sketch for a Red Ebay 128x160 display connected to a Seeeduino (switched to 3.3V GPIO)

Using library SD at version 1.2.3 in folder: C:\Program Files (x86)\Arduino-1.8.9\libraries\SD 
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino-1.8.9\hardware\arduino\avr\libraries\SPI 
Using library TFT at version 1.0.6 in folder: C:\Program Files (x86)\Arduino-1.8.9\libraries\TFT 
"C:\\Program Files (x86)\\Arduino-1.8.9\\hardware\\tools\\avr/bin/avr-size" -A "C:\\Users\\DAVIDP~1\\AppData\\Local\\Temp\\arduino_build_289647/kfitzm3_BMP.ino.elf"
Sketch uses 17134 bytes (53%) of program storage space. Maximum is 32256 bytes.
Global variables use 1026 bytes (50%) of dynamic memory, leaving 1022 bytes for local variables. Maximum is 2048 bytes.

It built ok. I do not have your “Words1.bmp”
So I displayed “lady.bmp” (128x160) or “miniwoof.bmp” (120x160)

The images are rendered but in Landscape mode with Red and Blue swapped.

I strongly recommend you to not use “TFT.h” library.

Install Adafruit_GFX and Adafruit_ST7735 via IDE Library Manager.
Run the spitftbitmap.ino from examples. e.g. my output:

Using library Adafruit-GFX-Library at version 1.5.5 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit-GFX-Library 
Using library Adafruit_ST7735_and_ST7789_Library at version 1.3.4 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_ST7735_and_ST7789_Library 
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino-1.8.9\hardware\arduino\avr\libraries\SPI 
Using library SD at version 1.2.3 in folder: C:\Program Files (x86)\Arduino-1.8.9\libraries\SD 
"C:\\Program Files (x86)\\Arduino-1.8.9\\hardware\\tools\\avr/bin/avr-size" -A "C:\\Users\\DAVIDP~1\\AppData\\Local\\Temp\\arduino_build_77277/spitftbitmap.ino.elf"
Sketch uses 21792 bytes (67%) of program storage space. Maximum is 32256 bytes.
Global variables use 1044 bytes (50%) of dynamic memory, leaving 1004 bytes for local variables. Maximum is 2048 bytes.

David.

Edit. File->Preferences: Show verbose compilation
This will show the library version(s) and location(s) like my pasted output.

Switched to SdFat and 2017 versions of the ST7735 library, but it’s still unable to find the file - even when I replaced it with the parrot bmp.

/***************************************************
  #include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library
#include <SPI.h>
#include <SdFat.h>

SdFat SD;

#if defined(__SAM3X8E__)
    #undef __FlashStringHelper::F(string_literal)
    #define F(string_literal) string_literal
#endif

// TFT display and SD card will share the hardware SPI interface.
// Hardware SPI pins are specific to the Arduino board type and
// cannot be remapped to alternate pins.  For Arduino Uno,
// Duemilanove, etc., pin 11 = MOSI, pin 12 = MISO, pin 13 = SCK.
#define SD_CS    4  // Chip select line for SD card
#define TFT_CS  10  // Chip select line for TFT display
#define TFT_DC   8  // Data/command line for TFT
#define TFT_RST  9  // Reset line for TFT (or connect to +5V)

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void) {
  Serial.begin(9600);

  // Our supplier changed the 1.8" display slightly after Jan 10, 2012
  // so that the alignment of the TFT had to be shifted by a few pixels
  // this just means the init code is slightly different. Check the
  // color of the tab to see which init code to try. If the display is
  // cut off or has extra 'random' pixels on the top & left, try the
  // other option!
  // If you are seeing red and green color inversion, use Black Tab

  // If your TFT's plastic wrap has a Black Tab, use the following:
  tft.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab
  // If your TFT's plastic wrap has a Red Tab, use the following:
  //tft.initR(INITR_REDTAB);   // initialize a ST7735R chip, red tab
  // If your TFT's plastic wrap has a Green Tab, use the following:
  //tft.initR(INITR_GREENTAB); // initialize a ST7735R chip, green tab

  Serial.print("Initializing SD card...");
  if (!SD.begin(SD_CS)) {
    Serial.println("failed!");
    return;
  }
  Serial.println("OK!");
  delay(1000);
  bmpDraw("Words1.bmp", 0, 0);
}

void loop() {
}

// This function opens a Windows Bitmap (BMP) file and
// displays it at the given coordinates.  It's sped up
// by reading many pixels worth of data at a time
// (rather than pixel by pixel).  Increasing the buffer
// size takes more of the Arduino's precious RAM but
// makes loading a little faster.  20 pixels seems a
// good balance.

#define BUFFPIXEL 20

void bmpDraw(char *filename, uint8_t x, uint8_t y) {

  File     bmpFile;
  int      bmpWidth, bmpHeight;   // W+H in pixels
  uint8_t  bmpDepth;              // Bit depth (currently must be 24)
  uint32_t bmpImageoffset;        // Start of image data in file
  uint32_t rowSize;               // Not always = bmpWidth; may have padding
  uint8_t  sdbuffer[3*BUFFPIXEL]; // pixel buffer (R+G+B per pixel)
  uint8_t  buffidx = sizeof(sdbuffer); // Current position in sdbuffer
  boolean  goodBmp = false;       // Set to true on valid header parse
  boolean  flip    = true;        // BMP is stored bottom-to-top
  int      w, h, row, col;
  uint8_t  r, g, b;
  uint32_t pos = 0, startTime = millis();

  if((x >= tft.width()) || (y >= tft.height())) return;

  Serial.println();
  Serial.print("Loading image '");
  Serial.print(filename);
  Serial.println('\'');

  // Open requested file on SD card
  if ((bmpFile = SD.open(filename)) == NULL) {
    Serial.print("File not found");
    return;
  }

  // Parse BMP header
  if(read16(bmpFile) == 0x4D42) { // BMP signature
    Serial.print("File size: "); Serial.println(read32(bmpFile));
    (void)read32(bmpFile); // Read & ignore creator bytes
    bmpImageoffset = read32(bmpFile); // Start of image data
    Serial.print("Image Offset: "); Serial.println(bmpImageoffset, DEC);
    // Read DIB header
    Serial.print("Header size: "); Serial.println(read32(bmpFile));
    bmpWidth  = read32(bmpFile);
    bmpHeight = read32(bmpFile);
    if(read16(bmpFile) == 1) { // # planes -- must be '1'
      bmpDepth = read16(bmpFile); // bits per pixel
      Serial.print("Bit Depth: "); Serial.println(bmpDepth);
      if((bmpDepth == 24) && (read32(bmpFile) == 0)) { // 0 = uncompressed

        goodBmp = true; // Supported BMP format -- proceed!
        Serial.print("Image size: ");
        Serial.print(bmpWidth);
        Serial.print('x');
        Serial.println(bmpHeight);

        // BMP rows are padded (if needed) to 4-byte boundary
        rowSize = (bmpWidth * 3 + 3) & ~3;

        // If bmpHeight is negative, image is in top-down order.
        // This is not canon but has been observed in the wild.
        if(bmpHeight < 0) {
          bmpHeight = -bmpHeight;
          flip      = false;
        }

        // Crop area to be loaded
        w = bmpWidth;
        h = bmpHeight;
        if((x+w-1) >= tft.width())  w = tft.width()  - x;
        if((y+h-1) >= tft.height()) h = tft.height() - y;

        // Set TFT address window to clipped image bounds
        tft.setAddrWindow(x, y, x+w-1, y+h-1);

        for (row=0; row<h; row++) { // For each scanline...

          // Seek to start of scan line.  It might seem labor-
          // intensive to be doing this on every line, but this
          // method covers a lot of gritty details like cropping
          // and scanline padding.  Also, the seek only takes
          // place if the file position actually needs to change
          // (avoids a lot of cluster math in SD library).
          if(flip) // Bitmap is stored bottom-to-top order (normal BMP)
            pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
          else     // Bitmap is stored top-to-bottom
            pos = bmpImageoffset + row * rowSize;
          if(bmpFile.position() != pos) { // Need seek?
            bmpFile.seek(pos);
            buffidx = sizeof(sdbuffer); // Force buffer reload
          }

          for (col=0; col<w; col++) { // For each pixel...
            // Time to read more pixel data?
            if (buffidx >= sizeof(sdbuffer)) { // Indeed
              bmpFile.read(sdbuffer, sizeof(sdbuffer));
              buffidx = 0; // Set index to beginning
            }

            // Convert pixel from BMP to TFT format, push to display
            b = sdbuffer[buffidx++];
            g = sdbuffer[buffidx++];
            r = sdbuffer[buffidx++];
            tft.pushColor(tft.Color565(r,g,b));
          } // end pixel
        } // end scanline
        Serial.print("Loaded in ");
        Serial.print(millis() - startTime);
        Serial.println(" ms");
      } // end goodBmp
    }
  }

  bmpFile.close();
  if(!goodBmp) Serial.println("BMP format not recognized.");
}

// These read 16- and 32-bit types from the SD card file.
// BMP data is stored little-endian, Arduino is little-endian too.
// May need to reverse subscript order if porting elsewhere.

uint16_t read16(File & f) {
  uint16_t result;
  ((uint8_t *)&result)[0] = f.read(); // LSB
  ((uint8_t *)&result)[1] = f.read(); // MSB
  return result;
}

uint32_t read32(File & f) {
  uint32_t result;
  ((uint8_t *)&result)[0] = f.read(); // LSB
  ((uint8_t *)&result)[1] = f.read();
  ((uint8_t *)&result)[2] = f.read();
  ((uint8_t *)&result)[3] = f.read(); // MSB
  return result;
}

Please report the actual version numbers. e.g. Preferences as shown in #1

Or by looking up each library in the Library Manager.

David.

Using library Adafruit_GFX_Library at version 1.5.6 in folder: /Users/kfitzm3/Documents/Arduino/libraries/Adafruit_GFX_Library
Using library Adafruit-ST7735-Library at version 1.0.8 in folder: /Users/kfitzm3/Documents/Arduino/libraries/Adafruit-ST7735-Library
Using library SPI at version 1.0 in folder: /private/var/folders/th/yhd_876n1cv3y157bc7312s80000gn/T/AppTranslocation/41E15F2B-DA9E-4CAA-94E4-1210606246BE/d/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/SPI
Using library SdFat at version 1.1.0 in folder: /Users/kfitzm3/Documents/Arduino/libraries/SdFat
/private/var/folders/th/yhd_876n1cv3y157bc7312s80000gn/T/AppTranslocation/41E15F2B-DA9E-4CAA-94E4-1210606246BE/d/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-size -A /var/folders/th/yhd_876n1cv3y157bc7312s80000gn/T/arduino_build_972410/spitftbitmap.ino.elf
Sketch uses 17466 bytes (54%) of program storage space. Maximum is 32256 bytes.
Global variables use 1107 bytes (54%) of dynamic memory, leaving 941 bytes for local variables. Maximum is 2048 bytes.

Thanks for your version numbers. I have updated my libraries.

Note that the current Adafruit_ST7735 class comes from Adafruit_ST7735_and_ST7789_Library which is supported by the IDE Library Manager.

You appear to be using Adafruit-ST7735-Library at version 1.0.8
GitHub says: ladyada released this on Jun 14, 2017

I would not trust v1.0.8 to work with modern Adafruit_GFX v1.5.6

I also note that Adafruit seem to have removed their standard "spitftbitmap.ino" example from Adafruit_ST7735 and Adafruit_ILI9341 Releases.
But you can still find it in their current Adafruit_HX8357 library.
Obviously you need to make minor adjustments to include, constructor and begin() statements to match the appropriate class.

Anyway. This is my build with updated libraries. (I even used your SdFat)

Using library Adafruit_GFX_Library at version 1.5.6 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_GFX_Library 
Using library Adafruit_ST7735_and_ST7789_Library at version 1.4.2 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_ST7735_and_ST7789_Library 
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino-1.8.9\hardware\arduino\avr\libraries\SPI 
Using library SdFat at version 1.1.0 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\SdFat 
"C:\\Program Files (x86)\\Arduino-1.8.9\\hardware\\tools\\avr/bin/avr-size" -A "C:\\Users\\DAVIDP~1\\AppData\\Local\\Temp\\arduino_build_584703/spitftbitmap.ino.elf"
Sketch uses 20678 bytes (64%) of program storage space. Maximum is 32256 bytes.
Global variables use 1039 bytes (50%) of dynamic memory, leaving 1009 bytes for local variables. Maximum is 2048 bytes.

General advice:

  1. run all the Adafruit_ST7735 examples
  2. run all the SD examples
  3. run all the SdFat examples.

You have never shown which 128x160 display you are using. e.g. link to Ebay sale
Most Ebay boards require 3.3V GPIO
Adafruit boards have level-shifter circuitry. You can use with 5V GPIO e.g. Uno

David.

I re-updated the ST7735 library. Any idea how to work around this?

/Users/kfitzm3/Documents/Arduino/spitftbitmap/spitftbitmap.ino: In function ‘void bmpDraw(char*, uint8_t, uint8_t)’:
spitftbitmap:179:31: error: ‘class Adafruit_ST7735’ has no member named ‘Color565’

Edit: It’s an adafruit board, it’s been working when I don’t use bitmaps and don’t use the SD card.

Nevermind - it was the fact that the c was capitalized. My bad. Examples are still not quite running properly with relation to "finding" the file on the SD card.

It works fine for me with SD.h or SdFat.h
The colours work fine too.

Adafruit update libraries frequently.
Sometimes with complete change of functionality and the same method() name.
e.g. setAddrWindow()
e.g. color565() and Color565()

All the same. Adafruit do a pretty good job for the world's benefit.

If you have a problem, just quote example.

At least your Adafruit hardware looks after the level shifting.
Red Chinese boards are not happy with 5V GPIO.

David.

I had to give the vcc pin 5v to get the sd card to work
using a cheap Chinese red 1.8 TFT SPI 128*160 V1.1

Yes. Those boards have an AMS1117-3.3V regulator that expects 5V on VCC.

There is often an unpopulated J1 footprint. Install an 0R if you want to bypass the regulator i.e. 3.3V on VCC

David.

I am wondering which 1.8" TFT you are using. I bought a red DS Tech 1.8" TFT screen with a yellow, 11-pin header on one side and I soldered on a 4-pin header on the other side. I had to do some research, from which I gathered the following…

…this type of SD card reader can only read SD cards up to 2GBs.

…in order for both the screen and the card reader to work, hardware SPI must be used. In the code at the top of this page, you have RST on pin 9 and DC on pin 8, but the Arduino TFT documentation has RST as 8 and DC as 9.

…images must be 24-bit RGB BMPs, and they must be in the root directory of the SD card.

I was able to get the screen to work (although it is annoyingly intermittent – one moment it will read a BMP file just fine, and the next it says that same file is not found – and any help with this would be greatly appreciated).

Here is the code I used:

+++++++

// SD - Version: Latest
#include <SD.h>

// SPI - Version: Latest
#include <SPI.h>

// TFT - Version: Latest
#include <TFT.h>

/*
This sketch was created for the DS Tech 1.8" TFT screen
(that uses the ST7735 driver) and the Arduino TFT library

In order to use the screen and the card reader together,
you must use hardware SPI, not software SPI

The pin breakout DS Tech 1.8" TFT screen is as follows:
VCC…5V
GND…GND
GND…
NC…
NC…
NC…
CLK…13 (also called SCK)
SDA…11 (also called MOSI)
RS…9 (also called DC)
RST…8 (also called RESET)
CS…10

SD_MISO…12
SD_SCK…13 (connected to screen CLK above)
SD_MOSI…11 (connected to screen MOSI above)
SD_CS…4

I soldered a four-pin header to the SD connections on
the DS Tech 1.8" TFT screen

The SD card must be 2G or less and formatted as FAT (FAT16)

To fit on the screen, all image files on the card must be pre-sized
to 160 by 128 pixels or less and must be 24-bit RGB BMPs
*/

// Set constants for the pins for the TFT display and SD card
#define CS 10
#define DC 9
#define RESET 8
#define SD_CS 4

// Create the TFT screen called myScreen
TFT myScreen = TFT(CS, DC, RESET);

// Create a picture unit called myPicture
PImage myPicture;

void setup() {
// Initialize the Serial object (for use with card reader)
Serial.begin(9600);

// Initialize the card reader
pinMode(SD_CS, OUTPUT);
digitalWrite(SD_CS, HIGH);

// The the next non-comment line replaces the more typical…
//myScreen.begin();
// If your screen colours are off, try one of the following:
// If your TFT’s plastic wrap has a Black Tab, use the following:
//myScreen.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab
// If your TFT’s plastic wrap has a Red Tab, use the following:
//myScreen.initR(INITR_REDTAB); // initialize a ST7735R chip, red tab
// If your TFT’s plastic wrap has a Green Tab, use the following:
//myScreen.initR(INITR_GREENTAB); // initialize a ST7735R chip, green tab
// Or try
//myScreen.initG(); // initialize a ST7735R chip, green tab

// Initialize the screen
myScreen.initR(INITR_BLACKTAB);

// Set screen orientation (could be 1 or 3 for landscape)
myScreen.setRotation(1);

// Initialize the SD card reader
Serial.print(“Initializing SD card…”);
if (!SD.begin(SD_CS)) {
Serial.println(“failed!”);
return;
}
Serial.println(“OK!”);

// Show the splash screen
myPicture = myScreen.loadImage(“splash.bmp”);
myScreen.image(myPicture,0,0);

+++++++

If you run this code using the serial monitor, you will see information on the SD card and the attemps to read files from it.

On another note, when I compile it, I get the error:

+++++++

In file included from C:\Program Files (x86)\Arduino\libraries\TFT\src/TFT.h:36:0,

from C:\Users\Documents\Arduino\Tricorder537C\Tricorder537C.ino:8:

C:\Program Files (x86)\Arduino\libraries\TFT\src/utility/Adafruit_GFX.h: In static member function ‘static PImage PImage::loadImage(const char*)’:

C:\Program Files (x86)\Arduino\libraries\TFT\src/utility/Adafruit_GFX.h:318:40: warning: converting to non-pointer type ‘int’ from NULL [-Wconversion-null]

if ((bmpFile = SD.open(fileName)) == NULL) {

+++++++

If anyone is able to decipher that error, I would appreciate the help.

I am quite new to Arduino and C.

Hope that might help.

I am wondering which 1.8" TFT you are using. I bought a red DS Tech 1.8" TFT screen with a yellow, 11-pin header on one side and I soldered on a 4-pin header on the other side. I had to do some research, from which I gathered the following...

Post a link to the actual screen that you bought. e.g. Ebay sale

...this type of SD card reader can only read SD cards up to 2GBs.

The Card reader is just a holder. The SD.h library will cope with most types and sizes of SD.

...in order for both the screen and the card reader to work, hardware SPI must be used. In the code at the top of this page, you have RST on pin 9 and DC on pin 8, but the Arduino TFT documentation has RST as 8 and DC as 9.

SD.h library always expects Hardware SPI e.g. 11,12,13 on a Uno. You can configure DC, RST, CS however you like.

...images must be 24-bit RGB BMPs, and they must be in the root directory of the SD card.

Yes. Limitation of your sketch. Not SD card. Nor limitation of SD.h library.

I was able to get the screen to work (although it is annoyingly intermittent -- one moment it will read a BMP file just fine, and the next it says that same file is not found -- and any help with this would be greatly appreciated).

The TFT.h library is deprecated. But I just tried TFTBitmapLogo.ino from RETIRED/TFT/Arduino examples
And it worked with a suitable .BMP file in the Root directory but with Rd/Blue swapped.

I strongly recommend that you use Adafruit_ST7735 library because it is maintained. (and has a sensible API)
We can find a suitable "spitftbitmap.ino" sketch.

It is always wise to start with library examples. Or proven code on the internet.
You can just quote the example "name" from any library that is supported by the IDE Library Manager. The world can find the code.

If you have an unknown library or code, make sure that you post a link.

Welcome to the Forum.

David.

Thank you very much for your response.

david_prentice:
Post a link to the actual screen that you bought. e.g. Ebay sale

I have attached a photo.

david_prentice:
The TFT.h library is deprecated. But I just tried TFTBitmapLogo.ino from RETIRED/TFT/Arduino examples
And it worked with a suitable .BMP file in the Root directory but with Rd/Blue swapped.

I strongly recommend that you use Adafruit_ST7735 library because it is maintained. (and has a sensible API)
We can find a suitable “spitftbitmap.ino” sketch.

I actually started with the Adafruit_ST7735 library and relied heavily on the examples. I ran into problems trying to read the card and send the file to the screen, so I tried it on the TFT library and had better luck. Perhaps you’re right. It may be time to go back and try the Adafruit library.

The annoying thing is that the sketch works perfectly. It’s only problem is that on the ninth BMP loaded (no matter which one it is), I get the “file not found” error message. I can load the same file nine times, or I can load nine different files. The ninth one always gets the error. For a while I got it up to ten, with the 11th causing the error, but it is back to the 9th again.

I read that the card reader and the screen might work on different voltages – with it being a 5V screen and a 3.3V reader. I put 1K resistors inline in the card reader CLK MOSI and CS pins. NO change. Then I bumped them all up to 2.2K and everything still works fine. Still no change.

I put a 1K resistor in line with the MISO with no change. (However, if I go to my battery pack – 3AA – then card reader does not initialize with the 1K on the MISO, I have to take it off.

I am thinking two things: maybe a higher resistor for the CLK MOSI and CS; or maybe there is some limiting factor in memory. Pushing the reset sets it all back to normal (with the 9th file problem still there though).

I tried posting the code here, but it was too long.

Again, any help is greatly appreciated.

Thanks for the photos. You have a board that can plug into the Analog and Power headers. (use Software constructor)

It is always wise to post a link if possible. I recognise the board. But I don’t know where you bought it. Or what software may have come with it.

I had to modify your sketch to make it run. Search for comments marked .kbv
I have no idea what “splash.bmp” should look like or where you got it. The photo “glares”.
I ran the program successfully with the “arduino.bmp” file that comes with the TFT library.

I strongly advise using Adafruit_ST7735 and Adafruit_GFX from the IDE Library Manager.
Build and run all the examples from a library.

Here is your sketch (as modified by me)

/*
This sketch was created for the DS Tech 1.8" TFT screen
(that uses the ST7735 driver) and the Arduino TFT library

In order to use the screen and the card reader together,
you must use hardware SPI, not software SPI

The pin breakout DS Tech 1.8" TFT screen is as follows:
 VCC........5V
 GND........GND
 GND........
 NC.........
 NC.........
 NC.........
 CLK........13 (also called SCK)
 SDA........11 (also called MOSI)
 RS.........9  (also called DC)
 RST........8  (also called RESET)
 CS.........10

 SD_MISO....12
 SD_SCK.....13 (connected to screen CLK above)
 SD_MOSI....11 (connected to screen MOSI above)
 SD_CS......4

I soldered a four-pin header to the SD connections on
the DS Tech 1.8" TFT screen

The SD card must be 2G or less and formatted as FAT (FAT16)

To fit on the screen, all image files on the card must be pre-sized
to 160 by 128 pixels or less and must be 24-bit RGB BMPs
*/

#include <SPI.h>  //.kbv must add these includes
#include <SD.h>
#include <TFT.h>  // Arduino LCD library

// Set constants for the pins for the TFT display and SD card
#define CS 10
#define DC 9
#define RESET 8
#define SD_CS 4

// Create the TFT screen called myScreen
TFT myScreen = TFT(CS, DC, RESET);

// Create a picture unit called myPicture
PImage myPicture;

void setup() {
    // Initialize the Serial object (for use with card reader)
    Serial.begin(9600);

    // Initialize the card reader
    pinMode(SD_CS, OUTPUT);
    digitalWrite(SD_CS, HIGH);

    // The the next non-comment line replaces the more typical...
    //myScreen.begin();
    // If your screen colours are off, try one of the following:
    // If your TFT's plastic wrap has a Black Tab, use the following:
    //myScreen.initR(INITR_BLACKTAB);   // initialize a ST7735S chip, black tab
    // If your TFT's plastic wrap has a Red Tab, use the following:
    //myScreen.initR(INITR_REDTAB);   // initialize a ST7735R chip, red tab
    // If your TFT's plastic wrap has a Green Tab, use the following:
    //myScreen.initR(INITR_GREENTAB); // initialize a ST7735R chip, green tab
    // Or try
    //myScreen.initG(); // initialize a ST7735R chip, green tab

    // Initialize the screen
    myScreen.initR(INITR_BLACKTAB);

    // Set screen orientation (could be 1 or 3 for landscape)
    myScreen.setRotation(1);

    // Initialize the SD card reader
    Serial.print("Initializing SD card...");
    if (!SD.begin(SD_CS)) {
        Serial.println("failed!");
        return;
    }
    Serial.println("OK!");

    // Show the splash screen
    myPicture = myScreen.loadImage("splash.bmp");
    //myPicture = myScreen.loadImage("arduino.bmp"); //.kbv comes with TFT.h examples
    myScreen.image(myPicture, 0, 0);
}

void loop(void)
{
    // .kbv empty loop
}

If you want help with a sketch, paste or attach the whole sketch. Then readers can build and debug it.
There is no need to post code from a library example. Just quote the example “name”.

David.

david_prentice:
If you want help with a sketch, paste or attach the whole sketch. Then readers can build and debug it.
There is no need to post code from a library example. Just quote the example "name".

David.

I used quite a few different libraries to get the code to do what I wanted. I tried to post the whole sketch, but it said it was too big. Is there another way to post sketches? (Sorry. Very new here.)

How to use the Forum

When editing a message, click [Preview]
This shows a link for [Attachments and other options]

Note that it accepts TXT, ZIP, INO, C, CPP, H, ..., JPG
but it does not like BMP

If you have "unliked files" put them into a ZIP. Attach the ZIP

Thanks again!

Any help would be appreciated. As it stands, the sketch works how I want it to, except it will not load whichever BMP is the ninth BMP. I can load the same BMP eight times just fine, but the ninth does not load with a “File not Found” error in the serial monitor.

Maybe the resistors are wrong.

Maybe I fried the card reader. (I did not use resistors at first.)

Maybe there is a way to clear the memory.

Tricorder537C.ino (15.9 KB)

TrekBMPs.zip (439 KB)

As I said earlier. TFT library is deprecated.

The loadImage() method is handy but only works with regular BMP files.
I have converted your “unusual” BMP files into the regular format BMP files that are understood by Arduino programs.

If you copy these BMP files to your Startrek project it should work.

I also include “spitftbitmap_ST7735” sketch with an example regular BMP file.
I have edited the original Adafruit sketch to display your “unusual format” BMP as well as regular 24-bit BMP.

Please let us know how you get on.

David.

bmps2.zip (449 KB)

spitftbitmap_ST7735.zip (60.3 KB)

I started with regular BMPs, but I thought that it might be an old screen that required an old type of BMP. It reads both kinds the same. Both kinds cause the ninth-BMP load error.