please help with 2.8 Spi display ili9341

I have two 2.4" boards like your one. One says T_DO and the other says T_OUT.

Your photo looks wrong to me. Perhaps this is a better diagram:

-   +    A    B    C    D     E  |  F   G   H   I   J
                                 |
                        oT_IRQ   |
                MISO----oT_OUT   |
                MOSI----oT_DIN   |
                 SCK----oT_CLK   |
o-----10k-----o         oT_CS o---4k7---o   o---------->D3
                   o    oMISO o---4k7---o   o---------->D12
    o--------------o    oLED
o-----10k-----o    o    oSCK  o---4k7---o   o---------->D13
o-----10k-----o    o    oMOSI o---4k7---o   o---------->D11
o-----10k-----o         oDC   o---4k7---o   o---------->D9
o-----10k-----o         oRST  o---4k7---o   o---------->D8
o-----10k-----o         oCS   o---4k7---o   o---------->D10
o------------------o    oGND -o---------o   o---------->GND
    o--------------o    oVCC  o---------o   o---------->5V
                                 |
                                 |
                                 |

The 10k plug between GND (-) column and column B 
The 4k7 plug between column E and column G i.e. across the V notch
The link wires from T_OUT, T_DIN, T_CLK, LED can go in column C
The display plugs into column D 
Run flying leads to the Uno.

Much easier with a 3.3V Arduino.  You just have straight wires to the Zero or Due.

I suggest that you omit the Touch jumper wires for the moment.
Just get the resistors correct for the TFT screen.

Then you can run regular examples from the Adafruit_ILI9341 library with this constructor:

Adafruit_ILI9341 tft(10, 9, 8);

I have run and tested programs on my similar TFT and Touchscreen.
When the TFT is working you can add the jumper wires on column C to enable the TouchScreen.

I am no good with cameras. Otherwise I could show you photos instead of diagrams.
Mind you, I can not identify the colour bands on your resistors from the photo.

David.

Edit. I have improved my diagram. Shows the columns better. To show where to insert wire links or resistors.

before I did try the Adafruit_ILI9341 library example "graphictest" with the wiring that posted before with the 1k resistors and it did work but it doesn't include the touch part wiring

I removed all the wires and reconnect again according to your last post.

With the new wiring the Adafruit_ILI9341 library example "graphictest" don't work.
(Note: it does upload but it doesn't show anything)

those are my arduinos

Uno.png

Nano.png

Only just looked at your PNG.

It seems to be Infiduino R3 which is switchable 3V / 5V

So life is good. Just switch to 3.3V and everything works beautifully.

I have attached a ZIP with different sketches, wiring diagram, flowchart.

I suggest that you use the "button_XPT2046.ino" wiring. i.e. edit
button_ibrahim.ino: #if 0
button_XPT2046.ino: #if 1

You will see that I got a 5V version working but it involved a lot of resistors.

David.

button_ibrahim.zip (4.55 KB)

Soo I wired my display similar to the upper wiring scheme the one without resistors.

I tried both "button_XPT2046.ino" and "button_resistive.ino" i didn't try "button_ibrahim.ino"

because I couldn't find "HCTFT_Touch.h" but both that I tried didn't work.

did they work for you?

and please if you can put a ling for "HCTFT_Touch.h"

Google "HCTFT_Touch" and you should find it on GitHub.
Or go to GitHub and search for it there.

If you can't find it, I will Zip it up and attach it for you.

David.

Edit. I found it on GitHub. Clicked the Green button [Clone or Download]. Downloaded ZIP to my PC.
From your IDE you can install the library e.g.:
Sketch->Include Library->Add .ZIP Library

As a general rule, you would only use libraries that are "approved" by the IDE Library Manager.
Be careful with unknown ZIP files that you find on the Internet.
Hobby Components provide good support for the products that they sell. The HCTFT_Touch library works well.

HCTFT_Touch-master.zip (9.18 KB)

the touch works on all of them but I can't see anything in the display it just a white screen.

I double-checked my wiring with the scheme that I sent you.
I am using a Seeeduino switched to 3.3V GPIO. Which should be the same as your Infiduino when you set the switch to 3.3V

I suggest that you print the wiring scheme on paper. Then check each coloured wire and tick them with a pencil.

You can't get a simpler wiring scheme. There is just one 33R to limit the LED current. And three links e.g. T_DIN to MOSI. T_OUT to MISO. T_CLK to SCK.

You can remove all four T_xxx connections. Then the Screen will be the only item on the SPI bus.

Note that jumper wires are not very reliable. Swap with good wires one at a time.
The RST pin must be under program control. The If the RST jumper wire is broken, the Screen will just show white.

David.

Edit. If you add a 10k resistor like this, the Touch Controller will be inactive by default.

-   +    A    B    C    D     E  |  F   G   H   I   J
                                 |
              oT_IRQ             
              oT_OUT      o
              oT_DIN  o   |
              oT_CS   |   |   o---------o   o       o------>D3 blue
              oT_CLK  | o |                 |
              oMISO   | | o   o---------o   |       o------>D12 orng
              oLED    | |     o---33R---o   |       o------>5V  RED    
              oSCK    | o     o---------o   |       o------>D13 blue
              oMOSI   o       o---------o  10k      o------>D11 grn
              oDC             o---------o   |       o------>D9  yell
              oRST            o---------o   |       o------>D8  orng
              oCS             o---------o   |       o------>D10 wht
              oGND            o---------o   |       o------>GND BLACK
              oVCC            o---------o   o       o------>3.3V ORANGE
                                 |
                                 |
                                 |
-   +    A    B    C    D     E  |  F   G   H   I   J

I don't want to hijack this thread but I'm curious to know the source of your 2.8" SPI TFT screens.
I've had two batches ( 2 per batch) from the same retailer:

Batch 1 had model number TJCTM24028-SPI and have a good touch screen.
Batch 2 had model number KMRTM28028-SPI and have a poor touch screen (also rotated 180 degrees compared with those in batch 1).

The rotation is no problem because I configure the screen in setup() with a simple 2 point calibration function which stores the mapping in EEPROM. But at least one has a dead area in bottom left hand corner and I had to hack a library to insert some dummy reads of the screen to get less random (and only just usable) results from it.

The other thing I noticed is that the screens claim to be 5v/3.3V compatible and even have a solder jumper marked J1 to bypass the regulator although I have used these only with 3.3 volt (ESP8266).

Anyway, good luck with your project.

I have only ever used with 3.3V logic (until this thread). Always with TFT, SD, XPT2046 on the same hardware SPI bus.

I have two 2.4 inch screens with Touch. Both are wired in Landscape. One is rotated 180 degrees. One corner is not quite accessible.

I have also used 2.2 inch screens without Touch.

They all work beautifully with 3.3V Seeeduino, 3.3V LGT8F328, Zero, Due, Nucleo, Teensy3.2, FRDM, ...

Fortunately Ibrahem has a 3.3V Infiduino. So everything should work nicely. However flying jumper wires are always risky.

Personally, I have made several pluggable Adapter shields with soldered routeing wires. This means that the wiring is known and reliable. I know that any problems will be down to my own software.

This thread has shown me some unexpected results.

  1. Wiring 5V logic via 6k8 / 10k potential dividers was fine for one SPI Slave but not for Touch and TFT.

  2. Wiring 5V logic via level shifter chips works fine with multiple SPI Slaves.

  3. Wiring 5V logic via 6k8 / 10k potential dividers. TFT on hardware SPI. Touch on bit-banged GPIO.

  4. XPT2046_Touchscreen library works fine on hardware SPI. e.g. on shared SPI bus

  5. The popular URTouch library has no concept of hardware SPI. It must be connected to dedicated GPIO pins. It handles the XPT2046 IRQ line completely wrong.

  6. The HCTFT_Touch library works fine with bit-banging the XPT2046 on dedicated GPIO pins.

I would guess that the 2.4 inch Touch and the 2.8 inch Touch will have the same wiring. e.g.
7. Backlight LED is connected between LED pin and GND. Wise to use 33R series resistor to limit current to 50mA.
8. Onboard LDO regulator provides 3.3V for ILI9341, XPT2046, SD Card via the VCC pin. You can connect 5V to the VCC pin.

Many people have used these Red 3.3V Displays over the years. I have always assumed that some people have used 5V logic. e.g. with level shifter chips, potential dividers, series resistors.
I have always understood that 5V logic will not work (as well as damaging the ILI9341)

David.

p.s. I happened to use 6k8/10k. 4k7/10k, 5k1/10k, 5k6/10k would be practical voltage dividers.
Bodmer advises 1k2/1k8 which create similar results (but with higher currents)

I guess the manufacturers of these boards feel under pressure to make generous claims about their voltage tolerance to increase the market potential, irrespective of the controller chip specification. The other thing that strikes me is the huge number of variants of each board meaning that if you buy the "same" board at different times, the chances are good that there are at least subtle differences to the ones previously purchased. I guess that there are huge numbers of surplus batches of screens from the mobile phone industry floating about, and if the size looks about right these are soldered onto the available boards and end up with the Ebay sellers.

Your comments definitely apply to the Mcufriend shields. Different controllers and Touch panels appear every few weeks. Making use of surplus screens.

The SPI ILI9341 screens have been pretty consistent. e.g. 2.2", 2.4", 2.8" all have the same ILI9341 controller.
Ok, Touch Panels might vary.
Some adverts "say" ILI9340. I have never seen an ILI9340 one.
But there are many Mcufriend screens that I have never seen. And many different Touch wiring and orientation.

David.

in the code, there is a couple of commands that I don't understand.

Serial.println((5.0 / 1024) * analogRead(A0));
on_btn.drawButton(false);
off_btn.drawButton(false);

what if I write true?

please if you can define that command.
and I want to ask if I want to add more buttons to the code.
can I just add another on/off button similar to the code or I have to do something else?.

Oops. the analogRead() was simply reading the voltage on Breadboard pins. I thought that I had removed the statement before posting the ZIP.

The Adafruit_GFX_Button class has lots of nice features.

For example. drawButton(true) will highlight the button. (false) just draws it normally.

You can use it to indicate that you have pressed the button or to show that a "Radio button" has changed state.

But the best feature of the Button class is that you can distinguish between isPressed, justPressed, justReleased, ...

You can refer to a button by name. You never have to worry about calculating Touch position.

You can set the position, size, colour, legend, ... of a button. Or add a new button very easily.
Note that a 40-key keypad uses up quite a lot of SRAM on a Uno for 40 buttons.

More typically, you have a 12-key phone pad or a few on-off buttons.

Explain what you want to do. We can probably show how to do it.

First off, you can experiment with different size buttons, different button positions, colours, ...

Your 3.3V Infiduino should work nicely with every ILI9341 library. Connect the SD Card and you can display BMPs as well.

David.

which word is the name of the button I have to change something here right?

on_btn.initButton(&tft, 80, 80, 100, 40, WHITE, GREEN, BLACK, "ON", 2);
off_btn.initButton(&tft, 240, 80, 100, 40, WHITE, RED, BLACK, "OFF", 2)

I can't just copy / paste it right?

You can read Adafruit tutorial on Overview | Adafruit GFX Graphics Library | Adafruit Learning System

Unfortunately it does not cover Buttons. This is from your Adafruit_GFX.h header. The methods are fairly intuitive:

class Adafruit_GFX_Button {

 public:
  Adafruit_GFX_Button(void);
  // "Classic" initButton() uses center & size
  void initButton(Adafruit_GFX *gfx, int16_t x, int16_t y,
   uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
   uint16_t textcolor, char *label, uint8_t textsize);
  // New/alt initButton() uses upper-left corner & size
  void initButtonUL(Adafruit_GFX *gfx, int16_t x1, int16_t y1,
   uint16_t w, uint16_t h, uint16_t outline, uint16_t fill,
   uint16_t textcolor, char *label, uint8_t textsize);
  void drawButton(boolean inverted = false);
  boolean contains(int16_t x, int16_t y);

  void press(boolean p);
  boolean isPressed();
  boolean justPressed();
  boolean justReleased();

 private:
  Adafruit_GFX *_gfx;
  int16_t       _x1, _y1; // Coordinates of top-left corner
  uint16_t      _w, _h;
  uint8_t       _textsize;
  uint16_t      _outlinecolor, _fillcolor, _textcolor;
  char          _label[10];

  boolean currstate, laststate;
};

you add a constructor for each button e.g.

Adafruit_GFX_Button david_btn;

then specify where to draw on the screen and what it looks like

    //note that x, y is the centre of the button.  w, h is the shape of button
    david_btn.initButton(&tft, 50, 50, 80, 20, WHITE, BLUE, BLACK, "Ibrahem", 1);

Just experiment with different buttons, different labels, colours etc.
And observe the difference between:

    david_btn.drawButton(true);
    david_btn.drawButton(false);

The press() method will update the current button state. Typically by using the contains(x, y) state. The isPressed(), justPressed(), justReleased() methods use this current state.

Only you know what you want to do. Describe it English. Then we can help you to implement it.
Think about common GUI on your PC. You use your mouse to hover or click on Buttons. You can do similar things on your tiny screen.

David.

I was trying to add a flicker to the code and I end up with that code.
but it doesn't work the way I wanted it to do.
if you can help me know what I did wrong.

project.ino (2.61 KB)

It is always wise to trace your logic in the flow diagram. e.g. with your pencil.

void loop(void)
{
    // READ TOUCH
    int pixel_x, pixel_y;
    bool down = ts.touched();
    if (down) {         //XPT2046_Touchscreen can use hardware
        TS_Point p = ts.getPoint(); //XPT_2046_touchscreen wired for LANDSCAPE
        pixel_x = map(p.x, TS_LEFT, TS_RT, 0, tft.width());
        pixel_y = map(p.y, TS_TOP, TS_BOT, 0, tft.height());
        //        tft.drawPixel(pixel_x, pixel_y, WHITE);
    }
    on_btn.press(down && on_btn.contains(pixel_x, pixel_y));
    off_btn.press(down && off_btn.contains(pixel_x, pixel_y));
    // update new buttons with new state
    flickeron_btn.press(down && flickeron_btn.contains(pixel_x, pixel_y));
    flickeroff_btn.press(down && flickeroff_btn.contains(pixel_x, pixel_y));
    if (on_btn.isPressed()) {
        digitalWrite(LED, HIGH);
        flag = 0;
    }
    if (off_btn.isPressed()) {
        digitalWrite(LED, LOW);
        flag = 0;
    }
    if (flickeron_btn.isPressed()) {
        flag = 1;
    }
    if (flickeroff_btn.isPressed()) {
        flag = 0;
    }
    if (flag == 1) {   //perform one blink per loop
        digitalWrite(LED, HIGH);
        delay(500);
        digitalWrite(LED, LOW);
        delay(500);
    }

}

There are two changes I have made. With your flowchart, you can observe how the program changes.

You should have a wider button to show the full "flickerOFF" label.
And you could try different colours.

David.