Arduino Mega 2560 and 3.2 tft lcd sainsmart with shield blank screnn

Hi noob here with arduino, tryng to run UTFT 320x240 demo on my 3.2 tft lcd screen with its shield. The program compiles and uploads just fine but the screen just remains blank and doesnt run demo. what should I do? I already changed the model parameter for my display module and the board and port are already set up.

Hi,

Post a link to the display so we can see what you have. There are a number of reasons why a display won't work:

  1. Wrong Voltage and/or logic levels driving the display
  2. Wrong driver library
  3. Incorrect configuration of library (pins used, interface used (SPI/parallel 8/16 bit) driver, screen size etc)
  4. Incorrect connections between Arduino and display
  5. Backlight LEDs not powered
  6. Display not reset correctly

When all these are right the displays work providing they have not been damaged in some way by badly connecting it up at some point in the past. So we need to know what your setup is because not many forum users are clairvoyant.

The Sainsmart 320x240 TFT Screen with SD Card and Shield has probably caused more headaches than any other board. I regrettable bought one and eventually got the demo to work. However I had a hard drive fail and lost the Sketch I found that actually worked.
Sainsmart totally refuse to respond to questions asked about this board and sites who used carry support like Rinky-Dinke, have a panel in red telling customers not to contact them for support as Sainsmart has plagiarised their software etc. They have removed all support data.

According to the SS website there are a number of PDF files and the UTFT libraries, I have tried them all and none work. Unfortunately I had no back-up of the of the file I had that got it working and cannot remember where I got it. There are a number of YouTube posts showing it working, but no one tells you how and what is necessary to get it working. Even the "mods" in the SS page have no effect.

I understand that the screen requires 3.3V, however if you are directly connecting to the Mega with the SS Shield then the shield is configured to supply the correct voltage to the display.

The suggested UTFT library should be placed in *:/Arduino/libraries/ But there are a large number of UTFT files from differing manufacturers and each seems to have differing parameters according their own products.

As far as I can establish the SainSmart board and shield are "allegedly" ITDB32S compat or the designation SSD1289 can be used - Both these are included in the UTFT.cpp and UTFT.h file definitions. (These files can be opened with Notepad++ as can the UNO files) Other suggestions I have found have been ITDB02_3.2, etc

My issue is that the screen lights up with back light, the Sketches open and compile but when trying to load I get the following error. The files are there and as far as I can see in the right place. You will also note that Arduino IDE also writes temp files in the Application Data folder (Normally hidden)

This is final paragraph of the compile error file I am getting:-

Quote. Using previously compiled file: C:\Users\Dave\AppData\Local\Temp\build2dbd151c9ebd88b118f7d8bbf05f5f27.tmp\libraries\UTFT\DefaultFonts.c.o
Using library UTFT in folder: F:\Arduino\libraries\UTFT (legacy)
GetFileAttributesEx F:\Arduino\libraries\UTFT\UTFT.cpp F:\Arduino\libraries\UTFT\UTFT.h: The filename, directory name, or volume label syntax is incorrect.
Error compiling. Unquote.

Any suggestions also appreciated. May this nut can be cracked and resolved as there are many people having these problems with the SS board. The answer seems to be a closely guarded secret.
I have also noted that some of the SS links to data pages have been suspended and now Error 404.

Cheers Dave

I decided I must be doing something (or not doing something) right/wrong and went back to square one.

I did a complete re-install of the Arduino IDE and did the following:

  1. Placed a fresh downloaded UTFT.zip file and placed it on the Desktop
  2. Opened Arduino IDE and the default Sketch tab and installed the UTFT.zip file (2nd row in list in include library)
  3. I then checked that the UTFT library was in the list
  4. I then ran the sketch that was displayed in the Arduino IDE panel. Verified then loaded to the Mega - OK no errors
    5 The sketch for UTFT_Demo_320X240 then appeared on the screen, this was then verified and loaded - no errors
  5. Viola. One Sainsmart TFT/SD/shield/Mega operational.
  6. Make sure you have the correct Board installed in tools and that the port is selected
  7. The text in the final panel can be edited in the INO file (Make backup first!)
  8. I have tried to make this clear for Newbs (like me) and remember "If you don't succeed at first, Try and Try again" :slight_smile:
  9. As mentioned earlier the interface SS Shield supplies the correct 3.3V for this display. There is no need to modify anything.

//Here is the memory Shield. If you do not run this nothing works Just a back lit screen

#include <memorysaver.h>
#include <UTFT.h>

void setup() {
// put your setup code here, to run once:

}

void loop() {
// put your main code here, to run repeatedly:

}

//*****END

==================================

// UTFT_Demo_320x240
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// This program is a demo of how to use most of the functions
// of the library with a supported display modules.
//
// This demo was made for modules with a screen resolution
// of 320x240 pixels.
//
// This program requires the UTFT library.
//

#include <UTFT.h>

// Declare which fonts we will be using
extern uint8_t SmallFont[];

// Set the pins to the correct ones for your development shield
// ------------------------------------------------------------
// Arduino Uno / 2009:
// -------------------
// Standard Arduino Uno/2009 shield : ,A5,A4,A3,A2
// DisplayModule Arduino Uno TFT shield : ,A5,A4,A3,A2
//
// Arduino Mega:
// -------------------
// Standard Arduino Mega/Due shield : ,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Mega : ,38,39,40,41
//
// Remember to change the model parameter to suit your display module!
UTFT myGLCD(ITDB32S,38,39,40,41);

void setup()
{
randomSeed(analogRead(0));

// Setup the LCD
myGLCD.InitLCD();
myGLCD.setFont(SmallFont);
}

void loop()
{
int buf[318];
int x, x2;
int y, y2;
int r;

// Clear the screen and draw the frame
myGLCD.clrScr();

myGLCD.setColor(255, 0, 0);
myGLCD.fillRect(0, 0, 319, 13);
myGLCD.setColor(64, 64, 64);
myGLCD.fillRect(0, 226, 319, 239);
myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(255, 0, 0);
myGLCD.print("* Universal Color TFT Display Library *", CENTER, 1);
myGLCD.setBackColor(64, 64, 64);
myGLCD.setColor(255,255,0);
myGLCD.print("http://www.RinkyDinkElectronics.com/", CENTER, 227);

myGLCD.setColor(0, 0, 255);
myGLCD.drawRect(0, 14, 319, 225);

// Draw crosshairs
myGLCD.setColor(0, 0, 255);
myGLCD.setBackColor(0, 0, 0);
myGLCD.drawLine(159, 15, 159, 224);
myGLCD.drawLine(1, 119, 318, 119);
for (int i=9; i<310; i+=10)
myGLCD.drawLine(i, 117, i, 121);
for (int i=19; i<220; i+=10)
myGLCD.drawLine(157, i, 161, i);

// Draw sin-, cos- and tan-lines
myGLCD.setColor(0,255,255);
myGLCD.print("Sin", 5, 15);
for (int i=1; i<318; i++)
{
myGLCD.drawPixel(i,119+(sin(((i*1.13)*3.14)/180)*95));
}

myGLCD.setColor(255,0,0);
myGLCD.print("Cos", 5, 27);
for (int i=1; i<318; i++)
{
myGLCD.drawPixel(i,119+(cos(((i*1.13)*3.14)/180)*95));
}

myGLCD.setColor(255,255,0);
myGLCD.print("Tan", 5, 39);
for (int i=1; i<318; i++)
{
myGLCD.drawPixel(i,119+(tan(((i*1.13)*3.14)/180)));
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,318,224);
myGLCD.setColor(0, 0, 255);
myGLCD.setBackColor(0, 0, 0);
myGLCD.drawLine(159, 15, 159, 224);
myGLCD.drawLine(1, 119, 318, 119);

// Draw a moving sinewave
x=1;
for (int i=1; i<(31820); i++)
{
x++;
if (x==319)
x=1;
if (i>319)
{
if ((x==159)||(buf[x-1]==119))
myGLCD.setColor(0,0,255);
else
myGLCD.setColor(0,0,0);
myGLCD.drawPixel(x,buf[x-1]);
}
myGLCD.setColor(0,255,255);
y=119+(sin(((i
1.1)3.14)/180)(90-(i / 100)));
myGLCD.drawPixel(x,y);
buf[x-1]=y;
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,318,224);

// Draw some filled rectangles
for (int i=1; i<6; i++)
{
switch (i)
{
case 1:
myGLCD.setColor(255,0,255);
break;
case 2:
myGLCD.setColor(255,0,0);
break;
case 3:
myGLCD.setColor(0,255,0);
break;
case 4:
myGLCD.setColor(0,0,255);
break;
case 5:
myGLCD.setColor(255,255,0);
break;
}
myGLCD.fillRect(70+(i20), 30+(i20), 130+(i20), 90+(i20));
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,318,224);

// Draw some filled, rounded rectangles
for (int i=1; i<6; i++)
{
switch (i)
{
case 1:
myGLCD.setColor(255,0,255);
break;
case 2:
myGLCD.setColor(255,0,0);
break;
case 3:
myGLCD.setColor(0,255,0);
break;
case 4:
myGLCD.setColor(0,0,255);
break;
case 5:
myGLCD.setColor(255,255,0);
break;
}
myGLCD.fillRoundRect(190-(i20), 30+(i20), 250-(i20), 90+(i20));
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,318,224);

// Draw some filled circles
for (int i=1; i<6; i++)
{
switch (i)
{
case 1:
myGLCD.setColor(255,0,255);
break;
case 2:
myGLCD.setColor(255,0,0);
break;
case 3:
myGLCD.setColor(0,255,0);
break;
case 4:
myGLCD.setColor(0,0,255);
break;
case 5:
myGLCD.setColor(255,255,0);
break;
}
myGLCD.fillCircle(100+(i20),60+(i20), 30);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,318,224);

// Draw some lines in a pattern
myGLCD.setColor (255,0,0);
for (int i=15; i<224; i+=5)
{
myGLCD.drawLine(1, i, (i1.44)-10, 224);
}
myGLCD.setColor (255,0,0);
for (int i=224; i>15; i-=5)
{
myGLCD.drawLine(318, i, (i
1.44)-11, 15);
}
myGLCD.setColor (0,255,255);
for (int i=224; i>15; i-=5)
{
myGLCD.drawLine(1, i, 331-(i1.44), 15);
}
myGLCD.setColor (0,255,255);
for (int i=15; i<224; i+=5)
{
myGLCD.drawLine(318, i, 330-(i
1.44), 224);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,318,224);

// Draw some random circles
for (int i=0; i<100; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=32+random(256);
y=45+random(146);
r=random(30);
myGLCD.drawCircle(x, y, r);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,318,224);

// Draw some random rectangles
for (int i=0; i<100; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(316);
y=16+random(207);
x2=2+random(316);
y2=16+random(207);
myGLCD.drawRect(x, y, x2, y2);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,318,224);

// Draw some random rounded rectangles
for (int i=0; i<100; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(316);
y=16+random(207);
x2=2+random(316);
y2=16+random(207);
myGLCD.drawRoundRect(x, y, x2, y2);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,318,224);

for (int i=0; i<100; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
x=2+random(316);
y=16+random(209);
x2=2+random(316);
y2=16+random(209);
myGLCD.drawLine(x, y, x2, y2);
}

delay(2000);

myGLCD.setColor(0,0,0);
myGLCD.fillRect(1,15,318,224);

for (int i=0; i<10000; i++)
{
myGLCD.setColor(random(255), random(255), random(255));
myGLCD.drawPixel(2+random(316), 16+random(209));
}

delay(2000);

myGLCD.fillScr(0, 0, 255);
myGLCD.setColor(255, 0, 0);
myGLCD.fillRoundRect(80, 70, 239, 169);

myGLCD.setColor(255, 255, 255);
myGLCD.setBackColor(255, 0, 0);
myGLCD.print("That's it!", CENTER, 93);
myGLCD.print("Restarting in a", CENTER, 119);
myGLCD.print("few seconds...", CENTER, 132);

myGLCD.setColor(0, 255, 0);
myGLCD.setBackColor(0, 0, 255);
myGLCD.print("Runtime: (msecs)", CENTER, 210);
myGLCD.printNumI(millis(), CENTER, 225);

delay (10000);
}

//end

bodmer:
Hi,

Post a link to the display so we can see what you have. There are a number of reasons why a display won't work:

  1. Wrong Voltage and/or logic levels driving the display
  2. Wrong driver library
  3. Incorrect configuration of library (pins used, interface used (SPI/parallel 8/16 bit) driver, screen size etc)
  4. Incorrect connections between Arduino and display
  5. Backlight LEDs not powered
  6. Display not reset correctly

When all these are right the displays work providing they have not been damaged in some way by badly connecting it up at some point in the past. So we need to know what your setup is because not many forum users are clairvoyant.

This is the display and shield that I got http://sainsmart.com/skin/frontend/base/default/document/3_2%20inch%20TFT%20with%20SD%20and%20Touch%20Quickstart.pdf

I used a Mega2560 and followed step by step the instructions in the pdf on the link above and the screen still remains blank.

Thunderbear:
The Sainsmart site is missing a number of links and that PDF is not reliable.
Follow the instructions I have given and you should be able to get it working, if it is a Sainsmart 320X240 TFT screen. :slight_smile: I found it is necessary to activate the memory file as shown on my system. I am running Win7 on a Dell 780SFF.

Purchasing a "genuine" Arduino UNO or Mega and Shields etc will save you a lot of headaches.
Some of the EBay "stuff" does work, but can be hairy to setup as they are Chinese clones and carry no information nor data support. They Sell - You buy - Goodbye :frowning:

You can copy and paste the txt data above and rename it as an .ino file. (Use Notepad++) If you use the basic MS Text editor do not save in ANSI but select Unicode 8.

Or you can go to my web site and download the TXT and INO files (NB Download the .ino or .txt files, not the DIR! place the files in a folder of the same name on your computer) at http://dsmithdale.net/arduino/ There are also some experimental shift register files there and an LED sequential shift register 4 wires in, switching 6 LEDs in sequence with reset in a loop.

Please be aware that the directory structure and the method of loading UTFT.zip and other Libraries are very important for successful compiling of files to your hardware. see tutorials on this and other recognised Arduino sites.

My Arduino page (FTP) is under construction and further details will be uploaded soon. Parent DIR will take you to my main pages.

Cheers Dave

Sploddy:
I decided I must be doing something (or not doing something) right/wrong and went back to square one.

I did a complete re-install of the Arduino IDE and did the following:

  1. Placed a fresh downloaded UTFT.zip file and placed it on the Desktop
  2. Opened Arduino IDE and the default Sketch tab and installed the UTFT.zip file (2nd row in list in include library)
  3. I then checked that the UTFT library was in the list
  4. I then ran the sketch that was displayed in the Arduino IDE panel. Verified then loaded to the Mega - OK no errors
    5 The sketch for UTFT_Demo_320X240 then appeared on the screen, this was then verified and loaded - no errors
  5. Viola. One Sainsmart TFT/SD/shield/Mega operational.
  6. Make sure you have the correct Board installed in tools and that the port is selected
  7. The text in the final panel can be edited in the INO file (Make backup first!)
  8. I have tried to make this clear for Newbs (like me) and remember "If you don't succeed at first, Try and Try again" :slight_smile:
  9. As mentioned earlier the interface SS Shield supplies the correct 3.3V for this display. There is no need to modify anything.

Hi Sploody, i followed step by step the instructions you listed and I'm still getting a blank screen. Now I do have couple of questions, I dont know if this is relevant or if it makes a difference but when i loaded the sample I did it as Arduino(AVR) and the non series version of the 320x240 sample not sure if that makes a difference, and also with the

#include <memorysaver.h>

part, I just copied and pasted that line, not sure if I have to do that or whether you were referring to another library I had to download. Also in the code the

#include <memorysaver.h>
#include <UTFT.h>

the memorysaver and UTFT are not highlighted orange so not sure if that is an issue. Also even though it compiles and uploads without errors it says on the bottom

"Build options changed, rebuilding all" and its followed by orange letters such as
C:\Users\Owner\Documents\Arduino\Libraries\UTFT\examples\Arduino (AVR)\UTFT_Demo_320x240.ino: In function 'void loop()':

And its repeated over an over and after the "320x240" part of each line it says

warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

then quotes strings such as

myGLCD.print("Runtime: (msecs)", CENTER, 210);

I really appreciate the help you have offered so far and looking forward to solve this problem through you expertise.

Hi Thunderbear: Hmm I am not sure what is happening: I have double checked that data file, in fact I copied off this post and ran it and it compiled perfectly.

I am far from being an expert on Arduino, also as mentioned I have been in electronics many years and whatever you work on the principal its always the same, Arduino does have exacting rules and regulation regarding compiling code and where the supporting attributes are located.

I went through the same problems as you did and I did a complete clean out of all files, because there was a lot of "junk" located in other directories. My set up is as follows.
the Arduino IDE is installed in my application drive. E:/Arduino/ This automatically creates files in the hidden 'Application Data' directory in Windows. You need to 'unhide' that and locate the ultimate directory, so you can delete any build up of dud data compilations. Also you will find files located in your documents.
Cleaning up your computer system is a good way to start and then start a fresh install.
I also have a number of working folders on my desktop which include zipped files that are needed for my devices 32lcd.zip UTFT.zip etc. These are on the desktop so they can be easily accessed.

The correct way to load a library into the Arduino IDE directory is as explained by opening the basic sketch by loading up Arduino IDE. Clicking on the Sketch button and select 'include library' then 'add .zip library' select the UTFT.zip file (do not unzip it) and add it. No bells nor whistles will ring or blow. if you go into that folder again you should see UTFT right at the bottom of the installed libraries, click on it and it will appear with two #include commands. The second command the UTF will be in orange if the two files are installed. Verify and then Compile. Again no B & W.
Go into the UTFT AVR directory and select the demo 320x240 ino It is not absolutely necessary, but Arduino can get a bit itchy with certain arangements of labeling. The file that you need to use can have the underscores removed so the label reads UTFT320x240.

I have run INO files from their folder on my desktop. This is possible when the libraries, have been correctly installed. This way you can copy a data file from the library and make alteration without corruption the original.

A final note is that if you are getting corrupts in the loading, it can be one of several things
Incorrect directory structure. This can occur when people insert libraries manually and not by the Sketch installer. Incorrect definition of the board, UNO or Mega? Incorrect definition of accepted name of device (display module) not excluding alternate modules by using // incorrect pin designations. Some have varying pin designations depending on the board.
Most importantly before running the sketch of choice, always check you have selected the correct board and that the board is plugged in to the USB socket and it has been found in device manager.
When swapping boards and using more that one USB port. Windows will allocate any com port up to 10. So double check.

When you load Arduino IDE. If you watch the panel on the screen you will see it does a search for software and hardware. By ensuring your hardware and the connections are in good condition, will eliminate any sideline issue. (On a previous project I wasted a lot of time, then found I had a brand new USB that had an intermittent connect. That ended up in the blender!)

If any of the experts on the forum can add further info, please do
Thanks Dave
Proof of the pudding attached.. Sorry about shaky hands!

IMG_3876.jpg

Sploddy:
Hi Thunderbear: Hmm I am not sure what is happening: I have double checked that data file, in fact I copied off this post and ran it and it compiled perfectly.

I am far from being an expert on Arduino, also as mentioned I have been in electronics many years and whatever you work on the principal its always the same, Arduino does have exacting rules and regulation regarding compiling code and where the supporting attributes are located.

I went through the same problems as you did and I did a complete clean out of all files, because there was a lot of "junk" located in other directories. My set up is as follows.
the Arduino IDE is installed in my application drive. E:/Arduino/ This automatically creates files in the hidden 'Application Data' directory in Windows. You need to 'unhide' that and locate the ultimate directory, so you can delete any build up of dud data compilations. Also you will find files located in your documents.
Cleaning up your computer system is a good way to start and then start a fresh install.
I also have a number of working folders on my desktop which include zipped files that are needed for my devices 32lcd.zip UTFT.zip etc. These are on the desktop so they can be easily accessed.

The correct way to load a library into the Arduino IDE directory is as explained by opening the basic sketch by loading up Arduino IDE. Clicking on the Sketch button and select 'include library' then 'add .zip library' select the UTFT.zip file (do not unzip it) and add it. No bells nor whistles will ring or blow. if you go into that folder again you should see UTFT right at the bottom of the installed libraries, click on it and it will appear with two #include commands. The second command the UTF will be in orange if the two files are installed. Verify and then Compile. Again no B & W.
Go into the UTFT AVR directory and select the demo 320x240 ino It is not absolutely necessary, but Arduino can get a bit itchy with certain arangements of labeling. The file that you need to use can have the underscores removed so the label reads UTFT320x240.

I have run INO files from their folder on my desktop. This is possible when the libraries, have been correctly installed. This way you can copy a data file from the library and make alteration without corruption the original.

A final note is that if you are getting corrupts in the loading, it can be one of several things
Incorrect directory structure. This can occur when people insert libraries manually and not by the Sketch installer. Incorrect definition of the board, UNO or Mega? Incorrect definition of accepted name of device (display module) not excluding alternate modules by using // incorrect pin designations. Some have varying pin designations depending on the board.
Most importantly before running the sketch of choice, always check you have selected the correct board and that the board is plugged in to the USB socket and it has been found in device manager.
When swapping boards and using more that one USB port. Windows will allocate any com port up to 10. So double check.

When you load Arduino IDE. If you watch the panel on the screen you will see it does a search for software and hardware. By ensuring your hardware and the connections are in good condition, will eliminate any sideline issue. (On a previous project I wasted a lot of time, then found I had a brand new USB that had an intermittent connect. That ended up in the blender!)

If any of the experts on the forum can add further info, please do
Thanks Dave
Proof of the pudding attached.. Sorry about shaky hands!

EUREKA!!! Sploddy thank you so much I finally got it to work! I really appreciate everything you have posted. Now time to move to phase 2, SD card. Wish me luck and thanks for the help bud! ;D

Congrats Thunderbear: Pleasure to assist. Having everything in the right place is paramount to succesfully setting up a sketch and loading it to the Arduino board. a single letter or number incorrectly typed will produce an error. No second prize. It has to be spot on first time. All the attributes in the right place :slight_smile:

Best wishes and good luck with future projects.
E&OE !!