Go Down

Topic: 3.2" LCD TFT ILI9341 Touch Screen does not work (Read 1 time) previous topic - next topic

avil

Hi Guys.

I've bought 3.2 Inch SSD1289 TFT LCD Display Module Touch Panel For Arduino 9.4 x 6.1cm Resolution Ratio 240 x 320
https://www.aliexpress.com/item/3-2-inch-240x320-TFT-LCD-module-Display-with-touch-panel-SD-card-than-128x64-lcd/1859106266.html

But received ILI9341 3.2"

Anyway, I tried to use it.
I've connected it to the Arduino Mega via 3.2 TFT shield.

Then I've tried to run example sketch on it: URTouch_ButtonTest_3.2.

My code
Code: [Select]

// URTouch_ButtonTest
// Copyright (C)2015 Rinky-Dink Electronics, Henning Karlsen. All right reserved
// web: http://www.RinkyDinkElectronics.com/
//
// This program is a quick demo of how create and use buttons.
//
// This program requires the UTFT library.
//
// It is assumed that the display module is connected to an
// appropriate shield or that you know how to change the pin
// numbers in the setup.
//

#include <UTFT.h>
#include <URTouch.h>

// Initialize display
// ------------------
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino Uno/2009 Shield            : <display model>,19,18,17,16
// Standard Arduino Mega/Due shield            : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Due       : <display model>,25,26,27,28
// Teensy 3.x TFT Test Board                   : <display model>,23,22, 3, 4
// ElecHouse TFT LCD/SD Shield for Arduino Due : <display model>,22,23,31,33
//
// Remember to change the model parameter to suit your display module!
UTFT    myGLCD(ILI9341_16,38,39,40,41);

// Initialize touchscreen
// ----------------------
// Set the pins to the correct ones for your development board
// -----------------------------------------------------------
// Standard Arduino Uno/2009 Shield            : 15,10,14, 9, 8
// Standard Arduino Mega/Due shield            :  6, 5, 4, 3, 2
// CTE TFT LCD/SD Shield for Arduino Due       :  6, 5, 4, 3, 2
// Teensy 3.x TFT Test Board                   : 26,31,27,28,29
// ElecHouse TFT LCD/SD Shield for Arduino Due : 25,26,27,29,30
//
URTouch  myTouch( 6, 5, 4, 3, 2);


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

int x, y;
char stCurrent[20]="";
int stCurrentLen=0;
char stLast[20]="";

/*************************
**   Custom functions   **
*************************/

void drawButtons()
{
// Draw the upper row of buttons
  for (x=0; x<5; x++)
  {
    myGLCD.setColor(0, 0, 255);
    myGLCD.fillRoundRect (10+(x*60), 10, 60+(x*60), 60);
    myGLCD.setColor(255, 255, 255);
    myGLCD.drawRoundRect (10+(x*60), 10, 60+(x*60), 60);
    myGLCD.printNumI(x+1, 27+(x*60), 27);
  }
// Draw the center row of buttons
  for (x=0; x<5; x++)
  {
    myGLCD.setColor(0, 0, 255);
    myGLCD.fillRoundRect (10+(x*60), 70, 60+(x*60), 120);
    myGLCD.setColor(255, 255, 255);
    myGLCD.drawRoundRect (10+(x*60), 70, 60+(x*60), 120);
    if (x<4)
      myGLCD.printNumI(x+6, 27+(x*60), 87);
  }
  myGLCD.print("0", 267, 87);
// Draw the lower row of buttons
  myGLCD.setColor(0, 0, 255);
  myGLCD.fillRoundRect (10, 130, 150, 180);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (10, 130, 150, 180);
  myGLCD.print("Clear", 40, 147);
  myGLCD.setColor(0, 0, 255);
  myGLCD.fillRoundRect (160, 130, 300, 180);
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (160, 130, 300, 180);
  myGLCD.print("Enter", 190, 147);
  myGLCD.setBackColor (0, 0, 0);
}

void updateStr(int val)
{
  if (stCurrentLen<20)
  {
    stCurrent[stCurrentLen]=val;
    stCurrent[stCurrentLen+1]='\0';
    stCurrentLen++;
    myGLCD.setColor(0, 255, 0);
    myGLCD.print(stCurrent, LEFT, 224);
  }
  else
  {
    myGLCD.setColor(255, 0, 0);
    myGLCD.print("BUFFER FULL!", CENTER, 192);
    delay(500);
    myGLCD.print("            ", CENTER, 192);
    delay(500);
    myGLCD.print("BUFFER FULL!", CENTER, 192);
    delay(500);
    myGLCD.print("            ", CENTER, 192);
    myGLCD.setColor(0, 255, 0);
  }
}

// Draw a red frame while a button is touched
void waitForIt(int x1, int y1, int x2, int y2)
{
  myGLCD.setColor(255, 0, 0);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
  while (myTouch.dataAvailable())
    myTouch.read();
  myGLCD.setColor(255, 255, 255);
  myGLCD.drawRoundRect (x1, y1, x2, y2);
}

/*************************
**  Required functions  **
*************************/

void setup()
{
// Initial setup
  myGLCD.InitLCD();
  myGLCD.clrScr();

  myTouch.InitTouch();
  myTouch.setPrecision(PREC_MEDIUM);

  myGLCD.setFont(BigFont);
  myGLCD.setBackColor(0, 0, 255);
  drawButtons(); 
  Serial.begin(9600);
}

void loop()
{
  while (true)
  {
    if (myTouch.dataAvailable())
    {Serial.write("t");
      myTouch.read();
      x=myTouch.getX();
      y=myTouch.getY();
     
      if ((y>=10) && (y<=60))  // Upper row
      {
        if ((x>=10) && (x<=60))  // Button: 1
        {
          waitForIt(10, 10, 60, 60);
          updateStr('1');
        }
        if ((x>=70) && (x<=120))  // Button: 2
        {
          waitForIt(70, 10, 120, 60);
          updateStr('2');
        }
        if ((x>=130) && (x<=180))  // Button: 3
        {
          waitForIt(130, 10, 180, 60);
          updateStr('3');
        }
        if ((x>=190) && (x<=240))  // Button: 4
        {
          waitForIt(190, 10, 240, 60);
          updateStr('4');
        }
        if ((x>=250) && (x<=300))  // Button: 5
        {
          waitForIt(250, 10, 300, 60);
          updateStr('5');
        }
      }

      if ((y>=70) && (y<=120))  // Center row
      {
        if ((x>=10) && (x<=60))  // Button: 6
        {
          waitForIt(10, 70, 60, 120);
          updateStr('6');
        }
        if ((x>=70) && (x<=120))  // Button: 7
        {
          waitForIt(70, 70, 120, 120);
          updateStr('7');
        }
        if ((x>=130) && (x<=180))  // Button: 8
        {
          waitForIt(130, 70, 180, 120);
          updateStr('8');
        }
        if ((x>=190) && (x<=240))  // Button: 9
        {
          waitForIt(190, 70, 240, 120);
          updateStr('9');
        }
        if ((x>=250) && (x<=300))  // Button: 0
        {
          waitForIt(250, 70, 300, 120);
          updateStr('0');
        }
      }

      if ((y>=130) && (y<=180))  // Upper row
      {
        if ((x>=10) && (x<=150))  // Button: Clear
        {
          waitForIt(10, 130, 150, 180);
          stCurrent[0]='\0';
          stCurrentLen=0;
          myGLCD.setColor(0, 0, 0);
          myGLCD.fillRect(0, 224, 319, 239);
        }
        if ((x>=160) && (x<=300))  // Button: Enter
        {
          waitForIt(160, 130, 300, 180);
          if (stCurrentLen>0)
          {
            for (x=0; x<stCurrentLen+1; x++)
            {
              stLast[x]=stCurrent[x];
            }
            stCurrent[0]='\0';
            stCurrentLen=0;
            myGLCD.setColor(0, 0, 0);
            myGLCD.fillRect(0, 208, 319, 239);
            myGLCD.setColor(0, 255, 0);
            myGLCD.print(stLast, LEFT, 208);
          }
          else
          {
            myGLCD.setColor(255, 0, 0);
            myGLCD.print("BUFFER EMPTY", CENTER, 192);
            delay(500);
            myGLCD.print("            ", CENTER, 192);
            delay(500);
            myGLCD.print("BUFFER EMPTY", CENTER, 192);
            delay(500);
            myGLCD.print("            ", CENTER, 192);
            myGLCD.setColor(0, 255, 0);
          }
        }
      }
    }
  }
}



The first thing is that I'm not sure if pins are correct if check info from aliexpress product page.

Could you please help me to init my touch screen in a correct way.

Thank you in advance.


david_prentice

It looks like the regular 40-pin pinout.   Convention normally numbers a 2x20 header  1,3,5...39,40,38..2 in an anti-clockwise direction.
You don't say which 40-pin Adapter Shield you are using.

I would expect the UTFT examples to work with:
Code: [Select]

UTFT    myGLCD(ILI9341_16,38,39,40,41);


It is your job to compare with your Adapter pinout.

Incidentally,  you can get some pretty good clues by just reading what is printed on the pcb.    e.g. 9341 or 1289

David.

avil


gustavoalmeida

Try:

UTFT    myGLCD(CTE32_R2,38,39,40,41);

Let us know. Works for me. Hope work for you.

keredg

Hi, i have a similar board and shield only the 2.4" version. I am very new to Arduino in all aspects.
My problem is all i get is a white screen, i have tried many libraries to get it working with no luck. i tried an adafruit serial test sketch and it printed to the com port fine but no graphics at all. I have tried it on the Uno and Mega boards. I have tried that many different libraries that my head is spinning
 
this is the tft screen

It says the lcd controler is ILI9325 but probably an older photo as marked on the board is V2.1_9341
and i connected it the same as in the photo

And the shield

I used the same shield on the Mega so basically the same pins as the uno i have to be careful as its only 3.3v
Any help would be appreciated(please take into consideration I'm a noob) as i'm at the point of getting another screen with pins down the side and no shield and take delight in crushing this one

TIA
Derek


david_prentice

Your TFT has lots of pins i.e. 40
This is too many for a UNO.   Your adapter probably does some fancy latching of data.   UTFT might understand it.   But it might not.

You normally have a 40-pin adapter like this shield for Mega2560
It looks after the 3.3V level shifting.    And most libraries like UTFT will understand the pinout wiring.

UTFT has no concept of reading the display ID.   It only understands "famous brand model numbers".
With an unbranded display,  you have to use guesswork.   e.g. ILI9325_16,  ILI9325_8, ILI9341_16, ...

David.

keredg

Thanks for the quick reply, since i posted i have been going back through almost the whole Displays part of the forum looking for answers, my eyes are like my white screen but only red  :o

Looking at the pins on the uno compared to the mega i can fit this shield directly onto the mega and it connects to the same corresponding pins ie. left side 3.3v to A5 and on the right 13 down to 2 and Tx Rx
pins, can i not use the mega till i get a shield to use the end rows on the mega.

Like this one
Quicker than from china

I was hoping to use the shield i have on the uno and only use a mega if i needed memory and more pins but if it won't work I'll just have to get the proper mega+shield.

In the meantime i'll retry the UTFT and V2.1_9341 thats actually printed on the board and maybe connect the necessary pins using a protaboard.
It will probably take till the middle of next week before i can get it as tomoz is holiday, saturday the delivery guys do not collect.....
Thanks again, I'll be back in a few days or sooner if i get things working.
Cheers
Derek

keredg

I did a quick test using Adafruit graphictestAS8 and got this from the serial output, at least something works

TFT LCD test
TFT size is 240x320
Benchmark                Time (microseconds)
Screen fill              1379540
Text                     32152
Lines                    1756680
Horiz/Vert Lines         141444
Rectangles (outline)     99664
Rectangles (filled)      3266296
Circles (filled)         1052868
Circles (outline)        1417244
Triangles (outline)      407932
Triangles (filled)       1485108
Rounded rects (outline)  486044
Rounded rects (filled)   3744880
Done!

david_prentice

I am pleased that you have got it to work.
Which library?

What does your Adapter contain?   i.e. what are the chip numbers?
Are they latches or buffers?

David.

keredg

Unfortunately only the serial output seams to work, nothing on the screen(yet)

I uses the library Adafruit_ILI9341_AS8 and selecting graphictest_AS8

The only chip on the back of the LCD screen is XPY2046 1528 What that is i have no idea

Can i interrogate through the serial to find out more?

keredg

Questions, If the Serial port is printing out logic and seemingly correct data but nothing appears on the TFT,

what could be the cause?

Wrong pin out
duff screen,
wrong controller chips selected

i'm looking for a pointer as where too start and where i am

If correct data is printing out does it mean i have the correct chip or can the arduino just read and write independently of the screen.

TIA(thanks in advance)

david_prentice

#7 said that it was working.

A graphics screen is not much good if it does not show anything.
Your Serial output just means that the AVR has not crashed.  Not that it has sent the correct commands to your TFT.

If you want help,  you should identify what adapter you have e.g. a website with accurate photos and schematic or instructions.

I would expect an ILI9341 cotroller with 8080-16 parallel interface.   Or possibly an 8080-8 interface.

Your Uno-style adapter is non-standard.    Provide information and you will get some practical advice.
If the vendor has supplied a library,  it  would be a good start.

David.

keredg

In #7 i did NOT say it was working,(please read again) i only said i was getting output text from the serial port and posted it.

This is the makers site/data I tried the examples with no luck,  the venders site that i also supplied(with photos)has nothing, its an ebay seller

I cannot find any usable data on the UNO style adapter, that is part of the reason i'm on here
I posted a link to the adapter from the vender, they did not supply any libraries(for either TFT or adapter)

All the information i have, you have.

thanks

david_prentice

We always have to use a some common sense when reading a post.   Especially from non-English speakers.

#7 made no mention of a white screen.  Just said at least something works

Your link shows a 3.3V TFT320_QVT screen with a standard 40-pin header.
Does your screen match that photo?

It is the adapter that we need to see.   Because Uno adapters are non-standard.

Looking through the ElecFreaks website,  I found TFT01 v1.0 adapter
And also  TFT01 v2.0 SHD09

Yes,  I understand that your shop site had unreadable photos and no technical details.
It is your job to find accurate information.   Hint.  Look for any text printed on the pcb.   Google "this text".   View sites until you find one with accurate photos.   Or at least say "looks like photo but printed text is different"  or "pcb traces are different"

Seriously.   You have bought an item and are having difficulties.
If you spend 10 minutes preparing a question,  you probably get the solution from the first reply.

When we have to draw blood out of a stone it involves guesswork and frustration.

Think about it.   You have struggled for days.   10 minutes to find accurate information.   That is why God gave us Google.

David.

keredg

Hello again David, it may not sound like it but i appreciate your help.

I am english, although a geordie (from Newcastle)may be classed as not english speaking :) but i have been living in Spain for some 25+ years.

No mention of white screen in #7 as it was a follow on from previous posts ie. #4 onwards. I do realise that you answer lots of different posts daily but if you spend the same 10 minutes(that you recomend to me) recaping over what you are about to answer, this clarification post and others throughout the forum would not be necessary.

The  TFT01 V1.0 adapter you link to is not the same as the one i posted a link to and is plainly visable if you compare the photos.
The version V2.0 is similar but the demo code does not work on the one i have as it is probably a bad copy.
The text on the adapter i have is
LSEESTUDIO
TFT SHIELD V1.0
1seeduino@gmail.co

I did find something similar(after googling) on a chineese site and i also wrote to the email address with no reply.
I have read numerous forums, downloaded numerous scripts(most won't even compile) watched at least 50 videos, downloading many examples with no luck.
All of which previous to posting here.
I also said i am a noob with arduino but i am not a noob in life and using internet to find what i need, I am 60 years old and i am a retired ships captain, you don't get where i am without applying some self help and common sence.

You probably have heard the saying "i can't see the wood for the trees" maybee this is a case but i can asure you that i have spent many hours looking and trying different things i have found on the net, i do not stop and shout for help at the first hurdle. I will find a solution one way or another, with or without your knowledgable help.
Thanks for your time posting, all i ask is you apply a bit of what you recomend others to do to yourself before answering.

Go Up