Image not showing on TFT display

Hi!

Im using a TFT LCD display, and im trying to show an image from the SD card. SD card has is being initialize and the image is being correctly identify from the sd card, however is not showing up on the screen. And yes, image is 24 bit bmp.

Im using an example code:


// include the necessary libraries
#include <SPI.h>
#include <SD.h>
#include <TFT.h>  // Arduino LCD library

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

TFT TFTscreen = TFT(TFT_CS, TFT_DC, TFT_RST);

// this variable represents the image to be drawn on screen
PImage logo;

void setup() {
  
  // initialize the GLCD and show a message
  // asking the user to open the serial line
  
  TFTscreen.begin();
  TFTscreen.background(255, 255, 255);

  TFTscreen.stroke(0, 0, 255);
  TFTscreen.println();
  TFTscreen.println("Arduino TFT Bitmap Example");
  TFTscreen.stroke(0, 0, 0);
  TFTscreen.println("Open serial monitor");
  TFTscreen.println("to run the sketch");
  delay(2000);

  // initialize the serial port: it will be used to 
  // print some diagnostic info  
  Serial.begin(9600);
  while (!Serial) {
    // wait for serial line to be ready
  }

  // clear the GLCD screen before starting
  TFTscreen.background(255, 255, 255);
  
  // try to access the SD card. If that fails (e.g.
  // no card present), the setup process will stop.
  Serial.print("Initializing SD card...");
  if (!SD.begin(SD_CS)) {
    Serial.println("failed!");
    return;
  }
  Serial.println("OK!");
  
  // initialize and clear the GLCD screen
  TFTscreen.begin();
  TFTscreen.background(255, 255, 255);

  // now that the SD card can be access, try to load the
  // image file.
  logo = TFTscreen.loadImage("2.bmp");
  if (!logo.isValid()) {
    Serial.println("error while loading i.bmp");
  }
  if (logo.isValid() == false) {
    return;
  }
  
  Serial.println("drawing image");

  // draw the image to the screen
  TFTscreen.image(logo, 0, 0);
}

void loop() {
  // we don't need anything here
}

You have two "pastes" of the sketch on this page.fixed

Do you see any diagnostic messages in the console?

Thanks. Just edited it

No, everything is working fine. This is what I get on the serial monitor:
image

But no image is displayed on the screen. I also get this warning when uploading:

warning: converting to non-pointer type 'int' from NULL [-Wconversion-null]
if ((bmpFile = SD.open(fileName)) == NULL) {

What, if anything, are you seeing on the display?

This messages doesn't correspond to the your revised code...

Do you see this in the TFT?

Nothing show up on the TFT. The screen stays white

Are you sure that the display is connected correctly? And what does it actually work?
You took the picture too early. First, make sure that at least the examples from the library work for you

This is how pins are connected to arduino nano. I've tried with other images and giving it some time, still nothing.

to make sure that the display works try to change the background color:

Did you connect the SD and TFT pins to the same pins of the Nano? try to disconnect the pins of SD-card and test the TFT

hmm. No changes on the screen when I change the color. I also tried running another code that doesn't involve the SD card and everything runs fine.

If I disconnect the SD pins (11,13) initialization fails, if i disconnect the TFT pins (11,13) everything runs okay but nothing comes up on the TFT screen.

According to the internet you can connect different system to the I2C pins.

You should disconnect them from SD-module only and not from TFT and adrduino. And of course you should remove all parts the code regarding to the SD from the sketch.
Than test, ether the TFT will works.

It is not a I2c connection, it is SPI... at least a connection of the SD card.

Its working! There was an error in the pin definition.

Thank you so much for helping.

1 Like

What exactly? TFT only or together with SD card?
Anyway my congratulaions :slight_smile:

Post your final drawing/picture and sketch. Asking for a friend. : )

This is how it worked for me, with an arduino nano every

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.