Connecting 3.5" TFT LCD Shield to Arduino UNO PROBLEMS!

Hey everyone, this is going to be long to provide the most comprehensive description of what is happening.

First off, I am new to Arduino. I am currently in a college class in which we are learning how to use them and have to make our own games with the Arduino, they are allowed to have a physical component but my group decided not to incorporate one.

Our game is a story based game on the Arduino. We have successfully connected a Wii Nunchuk controller to the RedBoard and the inputs from that work just fine. This will be the controller of our story based game that allows the user to play the different mini-games such as basic basketball based on how many times the user clicks a button before they swing their arm and a sort of DDR on the Arduino. This part of the project, the Nunchuk works well, but it is important that I mention it as it takes up two Analog pins.

The reason I bring this up is that we also have an LCD that we are wiring in and making graphics for (through .bmp imaged loaded onto an SD card). This is where we are having issues. Here’s what I can provide you with.

The screen is 100% wired correctly. I hooked up all the pins directly to the same pins on the RedBoard that they would go to if it was placed on top of the RedBoard. I also know that it works since I am able to use the MCUFRIEND_kbv.h Library graphics test and graphics appear on it, at least, the ones that are written into the code. When I try to run the ShowBMP example from the library though, it compiles and uploads, but the serial monitor returns the “cannot read SD.”

Now, this really goes against another library that I tried which was the TFT.h Library. That one said that it could read my SD card and went forward with trying to draw the image on the screen but would not, the backlight is all that appears on the screen for both.

My confusion lies in that I cannot seem to pinpoint what the issue is. The screen will display images but connecting the SD card seems to be issue. Thing is, one example says it cannot read it, the other can, and I don’t know where to go from here.

I’d like to point out that I tried using the Adafruit_GFX.h and Adafruit_TFTLCD.h libraries but could not find the commands I needed to just print an image from SD card.

Please help, this project is practically finished if I can figure out how to print to screen consistently! I also would rather the easiest way to do so, the MCUFRIEND_kbv.h library’s example on how to print to the screen takes up over 70% of program memory and is so complicated that I am certain that I could not replicate such a thing for all the images we have to print to the screen.

Are there any simple functions within TFT.h or any other library that will allow me to just call an image from the SD card? Help!

Attached below is the code that I need to be able to place the images in, the final code for our project, which includes the Nunchuk function. Also, LCD_Trials is what I am using to experiment with the LCD, let me know if there are any issues with that which would prevent the image being rendered. Thanks!

Code.ino (3.77 KB)

LCD_Trials.ino (1.41 KB)

Please say which Arduino. Please post a link to the actual screen you are using (or photo of pcb). What is the ID reported by MCUFRIEND_kbv ?

Update the MCUFRIEND_kbv library to the current v2.9.7 with the Library Manager.
There is a showBMP_Uno and a showBMP_not_Uno example.

David.

I am using an Arduino UNO sold by Sparkfun Electronics.

Screen: https://www.banggood.com/3_5-Inch-TFT-Color-Screen-Module-320-X-480-Support-Arduino-UNO-Mega2560-p-1022298.html?p=DQ30066511122014069J&utm_campaign=educ8stv&utm_content=huangwenjie&cur_warehouse=CN

MCUFRIEND_kbv.h ID:0xD3D3 (ID printed in the Serial monitor of the MCUFRIEND_kbv showBMP_Uno program)

I am aware that this program exists, it now is working for me in which it scrolls through the images on my SD card. A few issues I have with this:

  1. I do not understand the code- the function is very long and I don’t understand how to edit it for particular images if I want to place them in certain spots of my code.

  2. The size- This code takes up 76% of program memory just to display an image. I am looking for a simple way to call an image from the SD card so that it does not take up as much space as I have other libraries (for nunchuk) and the actual games I am making to fit into my project.

  3. Functionality- as mentioned before, this program just scrolls through images. I am looking for something that will allow me to display an image on the screen in a particular spot from the SD card when I call it rather than just scrolling through in one spot. Such as:
    if (catScore > 10 && wizardScore <= 10) {
    //display winning image
    }

else if (wizardScore > 10 && catScore <= 10){
//display losing image
}

You can reduce the size and complexity of the showBMP examples.

  1. only support 24-bit BMP. Most libraries supply 24-bit BMP examples.
  2. only have one BMP file on your SD

If all your BMPs are the same size and shape, you can convert your BMP files to RAW files with a PC program. Rendering a 240x320 RAW image from your SD on the TFT is very simple code.

All the same, the SD library and MCUFRIEND_kbv library are fairly big. So you need to be careful when using a 31.5kB Uno. e.g. avoid String operations. avoid floating point maths. avoid multiple Fonts.

In practice, it is easier to draw graphics from scratch. e.g. filled rectangle, circle, lines, ...
and it uses less code than using the SD library.

David.

David,

Thanks for the info. My issue lies in that with this game we will have shapes that may be much more complicated to draw than able to with the functionality of the commands which is why we are using paint, converting them to 320x480, saving them as 24-bit bmp files, and putting them on the SD card.

My question still lies whether or not there is another library other than MCUFRIEND_kbv that would work with the SD.h library well. I'm not married to the MCUFRIEND_kbv library, I kind of would rather use something else as the code seems much more complicated than I need.

Perhaps the TDT.h library or Adafruit_GFX? I'm not really sure. Is there any way to use any of these to call an image, all of which are in the root directory of the SD card, with one simple command?

Alex

If your images are photos or complex drawings, it is best to store on SD card.
I have already explained that RAW files are simpler. (and smaller than 24-bit BMP)

Adafruit_TFTLCD library comes with BMP examples. (only for 24-bit BMP)

I suggest that you quote some numbers e.g. size of binary when you build for a Uno (and it complains).

Tick the box for verbose Compile in Preferences.

David.