LCD display with ILI9341 driver on Arduino

There are several versions of SPI ILI9341 display modules.

Most have constructors like this:

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC/RST
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);

Note that the Adafruit examples omit the TFT_RST argument. Because the Adafruit boards have a hardware pullup on the TFT_RESET pin.

The Red modules from Ebay do not have a pullup resistor on TFT_RESET. So you must connect it to the Arduino. And you must configure it in the constructor.
In your case, you would use:

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC/RST
Adafruit_ILI9341 tft = Adafruit_ILI9341(10, 9, 8);

If you are using the TFTv2 library from my link you would need to re-wire your breadboard.

TFT_RST to digital #7  //the library expects a Backlight but it will perform the RESET function
TFT_DC   to digital #6
TFT_CS   to digital #5

I suggest that you make an adapter shield like TFTLCDCyg. It ensures your TFT projects are electrically and mechanically correct. You can wire the SD card onto the same hardware SPI bus as your TFT. And use the spare channel on your 4050 for SD_CS.

If you use the ILI9341 modules with an XPT2046 Touch controller, you need a channel for the TS_CS line. You could steal the TFT_RESET channel if you provide an external pullup resistor on the TFT_RST pin.

David.

TFTLCDCyg:

  1. Don´t connect TFT-MISO on MISO-Arduino (pin 12).

Tried not connecting it, no change. I don't think it's hurting anything if it's connected even if it's not being used. Might as well connect all the pins. Maybe in future I'll have some use for it like transferring a screenshot or something.

TFTLCDCyg:
2. VCC of CD4050 must be connected on 3.3V line.

Yep, as per my diagram, 3.3V.

TFTLCDCyg:
The library for ILI9341@MarekB it´s an excellent choise

D/l it and tested it... same result... black screen. The SS pin is at a constant 3.3V. The display is stubbornly not wanting to be sent any data.

The library looks good though, has documentation!

david_prentice:
There are several versions of SPI ILI9341 display modules.

Looks like the pins are identical if mine is slightly different. I guess the SPI interface should be the same, the only difference would be that pull up resistor that you mention further down in your post.

david_prentice:
Most have constructors like this:

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC/RST

Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);

I'm using MarekB's library now and the sketch I'm using has what you're talking about. My pins line up with the CS, DC and RST pins now. Well, they were correct, it's just that programatically, they are now defined.

/*
This sketch is demonstrating loading monochome images from a byte array.
The advantage of using monochrome images is its size. You could fit a fullscreen
monochrome image in Uno's program memory. You could not do that with
a full color image.
*/

#include "SPI.h"
#include "ILI9341_due_config.h"
#include "ILI9341_due.h"

#if defined(ARDUINO_ARCH_AVR)
#include <avr/pgmspace.h>
#elif defined(ARDUINO_SAM_DUE)
#define PROGMEM
#endif

const uint8_t arduLogo[] PROGMEM = {                                              // width 40, height 32
 B00000000, B00000000, B00000000, B00000000, B01111110,
 B00000000, B00000000, B00000000, B00000000, B00101110,
 B00000000, B00000000, B00000000, B00000000, B00101010,
 B00000001, B11111000, B00000000, B00001111, B10000000,
 B00000111, B11111110, B00000000, B00111111, B11100000,
 B00011111, B11111111, B10000000, B11111111, B11111000,
 B00111111, B00000111, B11000001, B11110000, B11111100,
 B00111100, B00000011, B11100011, B11100000, B00111100,
 B01111000, B00000000, B11110111, B10000000, B00011110,
 B01110000, B00000000, B01110111, B00000110, B00001110,
 B11100000, B00000000, B00111110, B00000110, B00000111,
 B11100001, B11111000, B00111110, B00011111, B10000111,
 B11100001, B11111000, B00011100, B00011111, B10000111,
 B11100000, B00000000, B00111110, B00000110, B00000111,
 B11110000, B00000000, B00111110, B00000110, B00001111,
 B01110000, B00000000, B01110111, B00000000, B00001110,
 B01111000, B00000000, B11110111, B10000000, B00011110,
 B00111100, B00000011, B11100011, B11100000, B00111100,
 B00111111, B00001111, B11000001, B11110000, B11111100,
 B00011111, B11111111, B00000000, B11111111, B11111000,
 B00000111, B11111100, B00000000, B00111111, B11100000,
 B00000001, B11110000, B00000000, B00001111, B10000000,
 B00000000, B00000000, B00000000, B00000000, B00000000,
 B00000000, B00000000, B00000000, B00000000, B00000000,
 B00000000, B00000000, B00000000, B00000000, B00000000,
 B01110011, B11001111, B00100010, B11100100, B01001110,
 B10001010, B00101000, B10100010, B01000100, B01010001,
 B10001010, B00101000, B10100010, B01000110, B01010001,
 B11111011, B11001000, B10100010, B01000101, B01010001,
 B10001010, B10001000, B10100010, B01000100, B11010001,
 B10001010, B01001000, B10100010, B01000100, B01010001,
 B10001010, B00101111, B00011100, B11100100, B01001110
};

// CS and DC for the LCD
#define LCD_CS 10 // Chip Select for LCD
#define LCD_DC 9 // Command/Data for LCD
#define LCD_RST 8 // Command/Data for LCD

ILI9341_due tft(LCD_CS, LCD_DC, LCD_RST);

void setup()
{
 Serial.begin(9600);
 tft.begin();
 tft.setRotation(iliRotation270); // landscape

 tft.fillScreen(ILI9341_BLACK); 

 tft.drawBitmap(arduLogo, 160, 100, 40, 32, ILI9341_DARKCYAN); // "transparent" background
 tft.drawBitmap(arduLogo, 110, 100, 40, 32, ILI9341_WHITE, ILI9341_DARKCYAN); 
}

void loop()
{

 /* add main program code here */

}

david_prentice:
Note that the Adafruit examples omit the TFT_RST argument. Because the Adafruit boards have a hardware pullup on the TFT_RESET pin.

That went a bit over my head. Did some basic reading on it, but I'll have to dig deeper to understand what pullup resistors are, what they do and whether I have it.

david_prentice:
The Red modules from Ebay do not have a pullup resistor on TFT_RESET. So you must connect it to the Arduino. And you must configure it in the constructor.
In your case, you would use:

// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC/RST

Adafruit_ILI9341 tft = Adafruit_ILI9341(10, 9, 8);

Yep the new sketch has this now. (lib is here ILI9341_due).

david_prentice:
You can wire the SD card onto the same hardware SPI bus as your TFT. And use the spare channel on your 4050 for SD_CS.

If you use the ILI9341 modules with an XPT2046 Touch controller, you need a channel for the TS_CS line. You could steal the TFT_RESET channel if you provide an external pullup resistor on the TFT_RST pin.

David.

Don't plan on using the SD slot nor is my unit touch, just interested in graphical output at this stage.

Correct me if I'm wrong since this is my first Arduino project, I add the library under sketch->include library.

Then I simply open the example sketch in the library examples folder and simply click, upload?

I don't need to compile the library .cpp and .h files?

Using this new example sketch, as I mentioned, I get 3.3V output from the 4050 SS pin.

I've actually got a couple of these units, I plugged in a different one (same version I think), same result. Nadda.

Your Fritzing looks clear. The connections look fine to me.

Providing your constructor() is accurate, Marek's ILI9341_due.h, Bodmer's TFT_ILI9341.h, Adafruit's Adafruit_ILI9341.h, ... should all work.

In fact most of these libraries will make some form of diagnostic report on the Serial Terminal. (you need to connect MISO line to #12. you do not need the 4050)

David.

@Atomic_Sheep

Have you identified pin 1 correctly and plugged the 4050 in the correct way around?

Is the backlight LED working? If it is, you should see some white light leaking out around the edges of the display.

david_prentice:
In fact most of these libraries will make some form of diagnostic report on the Serial Terminal. (you need to connect MISO line to #12. you do not need the 4050)

Will have to look into this.

bodmer:
@Atomic_Sheep

Have you identified pin 1 correctly and plugged the 4050 in the correct way around?

Yer pretty sure I'm right in this department.

Pin 1 is bottom right with the red cable.

bodmer:
Is the backlight LED working? If it is, you should see some white light leaking out around the edges of the display.

No the unit is completely blank.

Bought one of those Logic Level converter modules from Arduino.

Maybe there's something wrong with my 4050. I'll use it for the SS signal... see how I go.

Try this wiring

Constructor for the ILI9341_due library:

#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10
ILI9341_due tft = ILI9341_due(TFT_CS, TFT_DC, TFT_RST);

Figured it out :), I flipped an already flipped cable diagram, had my LCD connected back to front.

OOOOH I get it, so the SPI connections down one side are for the LCD and on the side for the SD reader?

Atomic_Sheep:
... and on the side for the SD reader?

Answer: Yes!

PD: up some pictures of your TFT

@TFTLCDCyg,

I see that you have connected LED to 3.3V.
The Uno has :

DC Current for 3.3V Pin 50 mA

The Uno's 3.3V regulator is a bit wimpy. It is safer to connect the LED to 5V via a 47R resistor.
And of course connect MISO to digital#12

Anyway, it is good that Atomic_Sheep has got the display working.

David.

Thanks for the help guys.

Here's a happy snap.

biboy:
Hy boys!

I bought a cheap 3.2" tft display from china, but the pin outs is not clever. Can you send me a workable wiring for this pin outs? I have an Arduino Uno. The display contain ILI9341 ic, sd card reader, and resistive touch screen, but my first goal is the screen start to work.

http://postimg.org/image/awbh9l5v5/

I attached a picture from modul's pinout.

Thanks!
Tibor

Hello, have you succeed ?
I have the same and it doesn't seem to be ILI9341 but SSD1289 (see 3.2TFT LCD - Geeetech Wiki)

Hello,

I bought a 2.4 TFT SPI ILI9341 display from ebay and I don't have a datasheet. I wired it up at 3.3V and turned it on. It works nice. The problem is that the 3.3V voltage regulator gets really hot. I used a variable power supply to power it up and the current draw is 0.13A. 0.03A for the arduino pro mini with 2 tiny LEDs and 0.1A for the display.

Is 0.1A for the display too much? If the display is OK maybe I should change the voltage regulator.

Hello
Just a feedback after 3 days debuging my problem and having a white screen all the time.
I used the wiring of Post 93 but with a 5V Pro Mini. In oder to gain the 3.3V I used a L78L33 voltage converter connected on the 5V pin. The wiring of Post 93 didn't work as long I had the VCC of the TFT on 3.3V (white screen flickering with LED13 during graphictest.ino). After I connected VCC of the TFT to the 5V pin on the Pro Mini....voila!
The empty InputB on the CD4050 was not necessary to put on GND to make it work.
I hope this info is helpful for others dealing with the same struggle as I did.

PS: I used oli's ucglib. HWSPI was faster than SWSPI.

casemod:
To make it easier on the folks here I modified the adafruit library.
The result is not as drastic as the parallel displays, but I managed to score a 2.40x speed increase.

The pins are defaulted to the hardware SPI.
9 and 10 are DC and CS. 13 is SCLK and 11 is MOSI. Simple

THE RESET PIN SHOULD BE ATTACHED TO 3.3V OR VCC TROUGH A 10K PULL-UP

The SD card library can be used as usual, with the default pinouts.

ili9341 2.2 and 2.4" Fast library for Arduino Uno, mini and nano - YouTube

Modified Library:

ILI9341 Test!

Display Power Mode: 0x0
MADCTL Mode: 0x0
Pixel Format: 0x0
Image Format: 0x0
Self Diagnostic: 0x0
Benchmark                Time (microseconds)
Screen fill              1522152
Text                    121600
Lines                    921592
Horiz/Vert Lines        126996
Rectangles (outline)    81808
Rectangles (filled)      3160352
Circles (filled)        501916
Circles (outline)        396440
Triangles (outline)      293484
Triangles (filled)      1163048
Rounded rects (outline)  183788
Rounded rects (filled)  3473156
Done!

Sketch uses 19,358 bytes (60%) of program storage space.
Global variables use 596 bytes (29%) of dynamic memory.




Default Library:



ILI9341 Test!
Display Power Mode: 0x0
MADCTL Mode: 0x0
Pixel Format: 0x0
Image Format: 0x0
Self Diagnostic: 0x0
Benchmark                Time (microseconds) Performance increase
Screen fill              2561344 1.68x
Text                    319432 2.62x
Lines                    3118828 3.38x
Horiz/Vert Lines        222976 1.75x
Rectangles (outline)    148504 1.81x
Rectangles (filled)      5319692 1.68x
Circles (filled)        1168236 2.32x
Circles (outline)        1357636 3.42x
Triangles (outline)      990332 3.74x
Triangles (filled)      2083636 1.79x
Rounded rects (outline)  511700 2.78x
Rounded rects (filled)  5964712 1.71x

					AVERAGE 2.40x faster

Done!

Sketch uses 19,008 bytes (58%) of program storage space.
Global variables use 596 bytes (29%) of dynamic memory.




Loading a BMP file from SD takes about the same time. About 200ms quicker.

The current library only works with arduino UNO, Mini and Nano. 
The previous version, posted in May works with the mega. For the Due there is an improved version using DMA.

Greeatings.

I have ILI9488 tft and mega .
I have problem with speed refreshing , I use iLI9488 library spi comunication beetween mcu and tft.
Have you some suggestion how can i speed up my tft have you some idea for this library or i must change hardware configuration ?

casemod:
To make it easier on the folks here I modified the adafruit library.
The result is not as drastic as the parallel displays, but I managed to score a 2.40x speed increase.

See links on Youtube or my Website (Excuse the mess it's under construction)

The pins are defaulted to the hardware SPI.
9 and 10 are DC and CS. 13 is SCLK and 11 is MOSI. Simple

THE RESET PIN SHOULD BE ATTACHED TO 3.3V OR VCC TROUGH A 10K PULL-UP

The SD card library can be used as usual, with the default pinouts.

Modified Library:

ILI9341 Test!

Display Power Mode: 0x0
MADCTL Mode: 0x0
Pixel Format: 0x0
Image Format: 0x0
Self Diagnostic: 0x0
Benchmark Time (microseconds)
Screen fill 1522152
Text 121600
Lines 921592
Horiz/Vert Lines 126996
Rectangles (outline) 81808
Rectangles (filled) 3160352
Circles (filled) 501916
Circles (outline) 396440
Triangles (outline) 293484
Triangles (filled) 1163048
Rounded rects (outline) 183788
Rounded rects (filled) 3473156
Done!

Sketch uses 19,358 bytes (60%) of program storage space.
Global variables use 596 bytes (29%) of dynamic memory.




Default Library:



ILI9341 Test!
Display Power Mode: 0x0
MADCTL Mode: 0x0
Pixel Format: 0x0
Image Format: 0x0
Self Diagnostic: 0x0
Benchmark Time (microseconds) Performance increase
Screen fill 2561344 1.68x
Text 319432 2.62x
Lines 3118828 3.38x
Horiz/Vert Lines 222976 1.75x
Rectangles (outline) 148504 1.81x
Rectangles (filled) 5319692 1.68x
Circles (filled) 1168236 2.32x
Circles (outline) 1357636 3.42x
Triangles (outline) 990332 3.74x
Triangles (filled) 2083636 1.79x
Rounded rects (outline) 511700 2.78x
Rounded rects (filled) 5964712 1.71x

AVERAGE 2.40x faster
Done!

Sketch uses 19,008 bytes (58%) of program storage space.
Global variables use 596 bytes (29%) of dynamic memory.




Loading a BMP file from SD takes about the same time. About 200ms quicker.

The current library only works with arduino UNO, Mini and Nano. 
The previous version, posted in May works with the mega. For the Due there is an improved version using DMA.

so where can i find your modified library?

KORMORAN098:
so where can i find your modified library?

On my website, at the bottom of the page there is a link for the ILI9341 variant.
Follow the video instructions (Should be super easy to install)

numlo:
Hello,

I bought a 2.4 TFT SPI ILI9341 display from ebay and I don't have a datasheet. I wired it up at 3.3V and turned it on. It works nice. The problem is that the 3.3V voltage regulator gets really hot. I used a variable power supply to power it up and the current draw is 0.13A. 0.03A for the arduino pro mini with 2 tiny LEDs and 0.1A for the display.

Is 0.1A for the display too much? If the display is OK maybe I should change the voltage regulator.

It seems like you're feeding 5V at the output of the regulator rather than the input. I would double check the connections again. Post a picture so we can help.

I tried all the steps according to the command, but nothing appeared on my LCD, can anyone tell me the reason?

sintad:
I tried all the steps according to the command, but nothing appeared on my LCD, can anyone tell me the reason?

What steps?
What command?
What LCD?

You can just quote message numbers. e.g. my LCD is the same as the one in #312
Or I followed the steps in the link posted in #328

It does not take much effort to provide information.
Most importantly, take notes on paper when you follow "steps".

Then you can say step 123 produced this result
Or at 23:45 in the video this happened.

There are many excellent tutorials, videos, diagrams, ... but you have to study them carefully.
Sometimes you will have questions. Or steps that you do not understand.

David.