TFT 2.4 inch screen isn't working

Hi guys. I was trying to build a sketching project with my tft 2.4 touchscreen shield. At first I tried to do it with my Arduino uno but it didn't work. Then I switched to my Arduino r4 wifi and it still didn't work. I tried uploading a basic code and that still didn't work.

#include <Arduino_GFX_Library.h>
#include <SPI.h>

// Display pins
#define LCD_CS 
#define LCD_DC A2
#define LCD_RST A4

// Setup display
Arduino_DataBus *bus = new Arduino_HWSPI(LCD_CS, LCD_DC);
Arduino_GFX *gfx = new Arduino_ILI9341(bus, LCD_RST);

// Colors
#define BLACK 0x0000
#define RED 0xF800
#define GREEN 0x07E0
#define BLUE 0x001F
#define WHITE 0xFFFF

// Drawing variables
int lastX = 0, lastY = 0;
bool firstTouch = true;

void setup() {
  Serial.begin(9600);
  
  // Initialize display
  gfx->begin();
  gfx->fillScreen(BLACK);
  
  // Draw test pattern
  gfx->fillRect(0, 0, 320, 30, RED);
  gfx->fillRect(0, 30, 320, 30, GREEN);
  gfx->fillRect(0, 60, 320, 30, BLUE);
  
  gfx->setTextColor(WHITE);
  gfx->setTextSize(2);
  gfx->setCursor(10, 100);
  gfx->println("Touch test - send X,Y");
  gfx->setCursor(10, 130);
  gfx->println("coordinates via Serial");
  
  Serial.println("Touch test ready - send X,Y coordinates");
}

void loop() {
  // Use serial input to simulate touch (format: "X,Y")
  if (Serial.available() > 0) {
    String input = Serial.readStringUntil('\n');
    
    if (input.indexOf(",") > 0) {
      int x = input.substring(0, input.indexOf(",")).toInt();
      int y = input.substring(input.indexOf(",") + 1).toInt();
      
      Serial.print("Touch at: ");
      Serial.print(x);
      Serial.print(",");
      Serial.println(y);
      
      // Draw touch point
      drawTouch(x, y);
    }
  }
}

void drawTouch(int x, int y) {
  // Clear previous position indicator
  gfx->fillRect(220, 200, 100, 30, BLACK);
  
  // Show touch position
  gfx->setCursor(220, 200);
  gfx->print(x);
  gfx->print(",");
  gfx->print(y);
  
  // Draw touch point
  if (firstTouch) {
    gfx->fillCircle(x, y, 3, WHITE);
    firstTouch = false;
  } else {
    // Draw line between last point and new point
    gfx->drawLine(lastX, lastY, x, y, WHITE);
    gfx->fillCircle(x, y, 3, WHITE);
  }
  
  lastX = x;
  lastY = y;
}

The full specs of the display shields are
HiLetgo 2.4" ILI9341 240X320 TFT LCD Display with Touch Panel LCD for Arduino UNO MEGA2560

https://www.amazon.com/HiLetgo-Display-ILI9341-240X320-Arduino/dp/B0722DPHN6?source=ps-sl-shoppingads-lpcontext&ref_=fplfs&psc=1&smid=A30QSGOJR8LMXA&gQT=2

Try one of the sample sketches that come with the Adafruit library.

Thank you so much I will try

I tried it but it didn't work :disappointed_face:. But I will send a picture if that will help.


can you share your wiring?

I have a similar module (pinout looks identical to photo in post 4) which works using the MCUFRIEND_kbv library

e.g. running File>Examples>MCUFRIEND_kbv>GLUE_Demo_320x240

// UNO mcufried_2_4_TFT_LCD
// File>Examples>MCUFRIEND_kbv>GLUE_Demo_320x240

// 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.
//

//################################################
// GLUE class that implements the UTFT API
// replace UTFT include and constructor statements
// remove UTFT font declaration e.g. SmallFont
//################################################

#include <UTFTGLUE.h>              //use GLUE class and constructor
UTFTGLUE myGLCD(0,A2,A1,A3,A4,A0); //all dummy args

// Declare which fonts we will be using
//extern uint8_t SmallFont[];      //GLUE defines as GFXFont ref

// Set the pins to the correct ones for your development shield
// ------------------------------------------------------------
// Arduino Uno / 2009:
// -------------------
// Standard Arduino Uno/2009 shield            : <display model>,A5,A4,A3,A2
// DisplayModule Arduino Uno TFT shield        : <display model>,A5,A4,A3,A2
//
// Arduino Mega:
// -------------------
// Standard Arduino Mega/Due shield            : <display model>,38,39,40,41
// CTE TFT LCD/SD Shield for Arduino Mega      : <display model>,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<(318*20); 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+(i*20), 30+(i*20), 130+(i*20), 90+(i*20));
  }

  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-(i*20), 30+(i*20), 250-(i*20), 90+(i*20));
  }
  
  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+(i*20),60+(i*20), 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, (i*1.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-(i*1.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);
}

photo of test run (TFT plugged into a UNO)

It worked with my Arduino r4 wifi... but the screen cracked. I don't know how :disappointed_face:. But on the bright side I will replace it and try again in a few days :slightly_smiling_face:.

maybe worth you having a look at ESP32-Cheap-Yellow-Display (usually called CYDs)
come with an onboard ESP32 microcontroller (with onboard WiFi, Bluetooth Classic and BLE) - has very limited GPIO facilities though

Would help to see how you have this wired up. I believe the display
is not setup to handle SPI, but instead it runs in a parallel
interface.

As mentioned in their product page:
2.4 inch TFT LCD Display Shield Touch Panel ILI9341 240X320 for Arduino UNO MEGA,Shenzhen HiLetgo Technology Co., Ltd

Where you need to wire up D0-D3 probably as minimum Or you may
need to wire up all 8 (D0-D7).

I have not played very much with the ILI9341 in parallel mode, so don't remember if you need all 8 data pins or if it can be configured
to only need D0-D7.

Sorry, not sure if Adafruit library supports parallel displays or not. My
quick looks, gives me the impression it probably does not as it is
derived from an SPI tft base class...

But I know there are others that do.
like:
An Adafruit one, but not sure how how up to date this one is as it
has not been updated in several years.

adafruit/TFTLCD-Library: Arduino library for 8-bit TFT LCDs such as ILI9325, ILI9328, etc\

The MCUFRIEND_kbv library has an example sketch, diagnose_TFT_support, that helps to identify the controller used on the display. There is also an example sketch for diagnosing and calibrating the touchscreen. When using alternate

The Adafruit library is fairly limited in which displays it will work with, mainly because these displays have a wide variety of controllers, and Adafruit concentrates on compatibility with displays that are sold on their own website. The MCUFRIEND_kbv library is much more generalized, and the author is active on this forum assisting people having problems with incompatible displays.

Okay thank you guys I will try it when I get my new screen.