2.4" touch screen display ili9341

hello

i have this display: http://www.ebay.co.uk/itm/240x320-2-4-SPI-TFT-LCD-Touch-Panel-Serial-Port-Module-with-PBC-ILI9341-5V-3-3V-/121414443081?pt=UK_BOI_Electrical_Components_Supplies_ET&hash=item1c44dd6049

but i will know how to connect the touchscreen to make it work with the adafruit ili9341 touch paint example. can anyone explain how to do that.

thanks

any please i need it hard?

bump

What is the chip with those many pins on the back (touch screen controller)?

Use the search button. There are at least 2 other topics with this information.

In a glance: Touch only works with UTF and utouch library and the controller is an SPI device which needs to be wired accordingly with the TFT sharing the SPI bus.

can i use the utouch libary only for the touch and adafruit libary for tft video?
controller is xpt2046.

edit:

or can i remove the controller to use the normal pins from the touch screen to use with the example?

arduino123456789: can i use the utouch libary only for the touch and adafruit libary for tft video? controller is xpt2046.

I have seen that the UTFT library (which is slow as hell) has very good support for menus, so if speed is not an issue I believe you will get better served with it. Any reason to want to use the Adafruit one specifically? Are you looking for the DMA capabilities Paul Stoffregen added?

arduino123456789: or can i remove the controller to use the normal pins from the touch screen to use with the example?

Quite possibly. I can confirm its a 4 pin resistive controller. Whenever that would be more of an hassle than a solution depends on many units you would like to use it for. It still requires modifications, according to the adafuit schematics. Personally I wouldn't bother.

the adafruit breakout touch paint example uses the normal touch screen output. no micro controller.

so can that work?

arduino123456789:
the adafruit breakout touch paint example uses the normal touch screen output.
no micro controller.

so can that work?

the adafruit breakout touch paint example:

/***************************************************
  This is our touchscreen painting example for the Adafruit ILI9341 Breakout
  ----> http://www.adafruit.com/products/1770

  Check out the links above for our tutorials and wiring diagrams
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional)
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/

/** NOT FOR USE WITH THE TOUCH SHIELD, ONLY FOR THE BREAKOUT! **/

#include <Adafruit_GFX.h>    // Core graphics library
#include <SPI.h>
#include <Adafruit_ILI9341.h>
#include "TouchScreen.h"

// These are the four touchscreen analog pins
#define YP A2  // must be an analog pin, use "An" notation!
#define XM A3  // must be an analog pin, use "An" notation!
#define YM 5   // can be a digital pin
#define XP 4   // can be a digital pin

// This is calibration data for the raw touch data to the screen coordinates
#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940

#define MINPRESSURE 10
#define MAXPRESSURE 1000

// The display uses hardware SPI, plus #9 & #10
#define TFT_CS 10
#define TFT_DC 9
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we're using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

// Size of the color selection boxes and the paintbrush size
#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;

void setup(void) {
 // while (!Serial);     // used for leonardo debugging
 
  Serial.begin(9600);
  Serial.println(F("Touch Paint!"));
  
  tft.begin();
  tft.fillScreen(ILI9341_BLACK);
  
  // make the color selection boxes
  tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
  tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
  tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
  tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN);
  tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
  tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);
 
  // select the current color 'red'
  tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
  currentcolor = ILI9341_RED;
}


void loop()
{
  // Retrieve a point  
  TSPoint p = ts.getPoint();
  
 /*
  Serial.print("X = "); Serial.print(p.x);
  Serial.print("\tY = "); Serial.print(p.y);
  Serial.print("\tPressure = "); Serial.println(p.z);  
 */
  
  // we have some minimum pressure we consider 'valid'
  // pressure of 0 means no pressing!
  if (p.z < MINPRESSURE || p.z > MAXPRESSURE) {
     return;
  }
  
  // Scale from ~0->1000 to tft.width using the calibration #'s
  p.x = map(p.x, TS_MINX, TS_MAXX, 0, tft.width());
  p.y = map(p.y, TS_MINY, TS_MAXY, 0, tft.height());

  /*
  Serial.print("("); Serial.print(p.x);
  Serial.print(", "); Serial.print(p.y);
  Serial.println(")");
  */

    
  if (p.y < BOXSIZE) {
     oldcolor = currentcolor;

     if (p.x < BOXSIZE) { 
       currentcolor = ILI9341_RED; 
       tft.drawRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*2) {
       currentcolor = ILI9341_YELLOW;
       tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*3) {
       currentcolor = ILI9341_GREEN;
       tft.drawRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*4) {
       currentcolor = ILI9341_CYAN;
       tft.drawRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*5) {
       currentcolor = ILI9341_BLUE;
       tft.drawRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     } else if (p.x < BOXSIZE*6) {
       currentcolor = ILI9341_MAGENTA;
       tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_WHITE);
     }

     if (oldcolor != currentcolor) {
        if (oldcolor == ILI9341_RED) 
          tft.fillRect(0, 0, BOXSIZE, BOXSIZE, ILI9341_RED);
        if (oldcolor == ILI9341_YELLOW) 
          tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, ILI9341_YELLOW);
        if (oldcolor == ILI9341_GREEN) 
          tft.fillRect(BOXSIZE*2, 0, BOXSIZE, BOXSIZE, ILI9341_GREEN);
        if (oldcolor == ILI9341_CYAN) 
          tft.fillRect(BOXSIZE*3, 0, BOXSIZE, BOXSIZE, ILI9341_CYAN);
        if (oldcolor == ILI9341_BLUE) 
          tft.fillRect(BOXSIZE*4, 0, BOXSIZE, BOXSIZE, ILI9341_BLUE);
        if (oldcolor == ILI9341_MAGENTA) 
          tft.fillRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, ILI9341_MAGENTA);
     }
  }
  if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
    tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
  }
}

ant it use this for thouch screen:

/** NOT FOR USE WITH THE TOUCH SHIELD, ONLY FOR THE BREAKOUT! **/

#include <Adafruit_GFX.h>    // Core graphics library
#include <SPI.h>
#include <Adafruit_ILI9341.h>
#include "TouchScreen.h"

// These are the four touchscreen analog pins
#define YP A2  // must be an analog pin, use "An" notation!
#define XM A3  // must be an analog pin, use "An" notation!
#define YM 5   // can be a digital pin
#define XP 4   // can be a digital pin

so connect the 4 touch screen pins(not they from the chip) to my arduino and it work?
if yes:
which pin that go to the controller is what?

any

Or can i try to connect the touchscreen pins random to arduino? can that damage my touchscreen? or does only the x and y pins chanch if not connect correctly?

arduino123456789: Or can i try to connect the touchscreen pins random to arduino?

:fearful: Do you actually know what the touchscreen pins send to the arduino? :fearful:

1.- U-Touch = XPT2046, touch pins: IRQ, DO, DIN, CS, CLK

2.- Adafruit-touch = STMPE610 or FT2606, touch pins: XP, YP, XN, YN

Then, Is it possible? IRQ, DO, DIN, CS, CLK = XP, YP, XN, YN ??????? :fearful: :fearful:

no,

but the breakout touch paint use the normal output from a 4 wire touchscreen. so can i solder wires direct to the touchscreen(not to the controller) and make it work? if yes: does it matter which pin i connect to the arduino to test the touchscreen and set the touchscreen pins later correct? and if i connect the pins not correct to arduino will my touchscreen broken?

arduino123456789: no,

arduino123456789: does it matter which pin i connect to the arduino to test the touchscreen and set the touchscreen pins later correct?

arduino123456789: the adafruit breakout touch paint example:

[...]
// These are the four touchscreen analog pins
#define YP A2  // must be an analog pin, use "An" notation!
#define XM A3  // must be an analog pin, use "An" notation!
#define YM 5   // can be a digital pin
#define XP 4   // can be a digital pin
[...]

Then "goggling" how a resistive touchscreen works will bring an answer to your question.

arduino123456789: but the breakout touch paint use the normal output from a 4 wire touchscreen. so can i solder wires direct to the touchscreen(not to the controller) and make it work? if yes: does it matter which pin i connect to the arduino to test the touchscreen and set the touchscreen pins later correct? and if i connect the pins not correct to arduino will my touchscreen broken?

yes, you can use that, but it will be just as hard as getting the driver for the correct touch screen, so why going trough all that work? Unless, as I asked, and don't recall seeing an answer, you have some specific reason to use the adafruit example

casemod: Any reason to want to use the Adafruit one specifically?

i will use the adafruit libary becouse i made all my code for the screen it that and now i will add touch interface.

arduino123456789: i will use the adafruit libary becouse i made all my code for the screen it that and now i will add touch interface.

This is my suggestion (Oddly no one else is contributing?)

Assuming you have access to the output of the touch try this library

https://github.com/adafruit/Touch-Screen-Library

You can also do the same, but wire them to a STMPE610 touch controller and use this guide: https://learn.adafruit.com/downloads/pdf/adafruit-2-8-tft-touch-shield-v2.pdf

Check page 20,

Before you start stripping things I assumed you tried the adafruit library with that controller properly wired. I know it sounds odd, but I would not be surprised if it worked with minor mods.

but can my touchscreen go broken when i connect it wrong? i can't find it on the web

arduino123456789: but can my touchscreen go broken when i connect it wrong? i can't find it on the web

I doubt it will get "broken" if improperly wired to the arduino, but physically damaged if you wish to re-wire it other than the stock way, quite possibly. The connector is rather small.

casemod:

arduino123456789: but can my touchscreen go broken when i connect it wrong? i can't find it on the web

I doubt it will get "broken" if improperly wired to the arduino, but physically damaged if you wish to re-wire it other than the stock way, quite possibly. The connector is rather small.

ok, so if i not connect correct it will be broken?