LCD display with ILI9341 driver on Arduino

Hi
Thankx for your help, but does a library for ili9341 works for a chip ili9331?
Regards skimmie

My inattention. I read driver type 9341 from header

Hi everyone,

First of all, thanks for the supporting in this thread. This make Arduino easier.
Well, about my post. I have bought this module:

And I have Arduino UNO (with 3 weeks lifetime).

This module has the possibility of ARduino connection:
http://www.buydisplay.com/arduino/Interfacing-TFT-LCD-Module-with-ILI9341-Controller-to-Arduino.pdf

I'm trying, for one week, to connect it and... I give up, I need help.

I have tried to use the official sketch from the webpage (at bottom page). And I have tried to use Adafruit library too:

Ok. Lets start with wiring.
As I can see in datasheet, the interface between module and Arduino it's something like:

Module


//Display
Pin 1 -----> GND Arduino
Pin 2 -----> 3,3V (I have tried 5V too)
Pin 21 ----> Reset
Pin 23 ----> CS
Pin 24 ----> SCL
Pin 25 ----> D/C
Pin 27 ----> SDI
Pin 29 ----> Backlight
//Touch panel
Pin 30 ----> TP_CS
Pin 31 ----> TP_Pen
//SD card I guess
Pin 32 ----> SDO
Pin 33 ----> SCLK
Pin 34 ----> SDI
Pin 40 ----> GND Arduino

In my case, I want to start using display mode, so, I connect as the ADafruit library seems to say:
CS(Pin 23) -> Port 9 Arduino UNO
D/C(Pin 25) -> Port 10 Arduino UNO
SCL(Pin 24) -> Port 13 ARduino UNO
SDI(Pin27) -> Port 11 Arduino UNO
Backlight(Pin 29) -> 3,3V

Reset is not connected (I have tried to connect to VCC and define one dedicated port)
About library.
With these connections and Adafruit library I get white screen. Always white screen.
With the official webpage library I get error after error compiling. I can't get to compile the code.
This is the situation. Does someone idea about how to fix this problem?
I appreciate any idea to move on.

Thanks a lot!

Regards,

I put here how I got my setup working with Arduino Mega 2560.

STUFF:

-Arduino Mega 2560
-2.2 inch Serial SPI TFT LCD Display Module 240x320 ILI9341
-Library GitHub - Seeed-Studio/TFT_Touch_Shield_V1: Seeed Tft Touch Shield V1.0
-Arduino IDE 1.6.0
-CD4050 Hex/Buffer/Converter

Firs wiring...

Dosen't matter what pins you use from CD4050 just remember OUTPUT is what going TO tft lcd, and INPUT is FROM ARDUINO MEGA.

PIN ORDER:

These connect with CD4050

ARDUINO PIN D7 ---> CD4050 ---> tft LED
ARDUINO PIN D6 ---> CD4050 ---> tft D/C
ARDUINO PIN D5 ---> CD4050 ---> tft CS
ARDUINO PIN D4 ---> CD4050 ---> tft RESET
ARDUINO PIN 51 ---> CD4050 ---> tft SDI (MOSI)
ARDUINO PIN 52 ---> CD4050 ---> tft SCK

These connect straight form arduno to tft

ARDUINO PIN D50 ------------------> tft SDO (MISO)
ARDUINO 3,3V ----------------------> tft VCC
ARDUINO GND ----------------------> tft GND

CD4050 VCC ------------------------> ARDUINO 3,3V
CD4050 GND ------------------------> ARDUINO GND

Add your seed Library to Arduino IDE

Go to folder and find TFTv2.h file, and open it with texteditor (MAC) (notepad for windows i think)

in that TFTv2.h file is following lines

#define TFT_RST_OFF {DDRD |= 0x10;PORTD |= 0x10;}
#define TFT_RST_ON {DDRD |= 0x10;PORTD &=~ 0x10;}

You must change those two to

#define TFT_RST_OFF {DDRG |= 0x20;PORTG |= 0x20;}
#define TFT_RST_ON {DDRG |= 0x20;PORTG &=~ 0x20;}

now upload connect your Arduino to computer and run test sketch and you should be up and running.

2 MikiL

What voltage at CD4050 VCC pin? When I connect one CD4050 input to 5V voltage at VCC about 4.2V (not 3.3V).

avhohlov:
2 MikiL

What voltage at CD4050 VCC pin? When I connect one CD4050 input to 5V voltage at VCC about 4.2V (not 3.3V).

Connect CD4050 VCC Pin to ARDUINO's 3,3V PIN :slight_smile:

When I connect CD4050 VCC to Arduino 3.3V and one input to Arduino 5V voltage at CD4050 VCC (and Arduino 3.3V) about 4.2V

avhohlov:
When I connect CD4050 VCC to Arduino 3.3V and one input to Arduino 5V voltage at CD4050 VCC (and Arduino 3.3V) about 4.2V

All power connection's go 3,3V, do not put anything in 5V Output... If you using MEGA 2560, follow my earlier post and you see there power pin goes to 3,3V ARDUINO PIN

I have Arduino Uno. As I understand signal voltages of Uno and Mega are same (5V). Display
requires 3.3V signals (not 5V). When display disconnected and only Arduino board and CD4050 are in scheme (CD4050.VCC connected to Arduino 3.3V) I see 4.2V at CD4050.VCC.

I use CD4050 from http://www.ebay.com/itm/2PCS-CD4050-IC-BUFF-CONVERTER-HEX-DIP16-NEW-GOOD-QUALITY-D14-/301595571771?pt=LH_DefaultDomain_0&hash=item46387f363b

avhohlov:
When I connect CD4050 VCC to Arduino 3.3V and one input to Arduino 5V voltage at CD4050 VCC (and Arduino 3.3V) about 4.2V

You can try to use 74lvs245 to convert the 5 volt signals >> 3.3 SPI, then we put 4050 and nourishes the bunch 3.3 Volt. Good luck.

How about a better part: cd74HC4050
"The ’HC4049 and ’HC4050 are fabricated with high-speed
silicon gate technology. They have a modified input
protection structure that enables these parts to be used as
logic level translators which convert high-level logic to a low level
logic while operating off the low-level logic supply. For
example, 15-V input pulse levels can be down-converted to
0-V to 5-V logic levels."

Many folks use these to convert 5V to 3.3v for SD & uSD cards for example.
http://www.digikey.com/product-detail/en/CD74HC4050E/296-9213-5-ND/376792

vs older, slower cd4050
http://www.digikey.com/product-detail/en/CD4050BE/296-2056-5-ND/67303

Got to stop buying parts from e-bay and get them from reputable distributors.

I bought that same 2.8" display and after many attempts, I finally got my display to work with a few 2k2 and 4k7 resistors. I bought the Hex Buffer chip, CD4050BE, but the voltage was leaking through to a few of the pins and the chip did not work. (Perhaps I just have a bad batch, that's my luck). Anyways the display works but it is incredibly slow and can't really use my DUE, because I want everything to be as compact as possible.

I'm making a multi-purpose controller. It will have the feel of a gaming controller (Actually similar to a PSP) but it will have a touchscreen keyboard, duel PSP joysticks, an accelerometer/gyroscope, D-pad + action buttons and shoulder buttons. It will also have Bluetooth, Wifi, and RF, (no real purpose to have all three, but I will find a use for them)

@CrossRoads
Do you sell any boards similar to this, but with the same processing speed as a DUE?
http://www.ebay.com/itm/161757302117?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

2 CrossRoads

I test Philips 74HC4050N + 3-to-5V level shifter on BC547 and it seems work correct.
Direct connection ILI9340.SDO to Arduino.MISO also seems work.

When connecting a 3V level device to a 5V Arduino, I find the following points very helpful:

To all that come here after this post trying to get these displays working. Weeks ago I was in the same spot. I bought my cheap display and all I wanted to do was hook it up and see pretty colors. That did not go so well. But now after I have spent the last 10 days READING all of these posts and following up with the links, photos and sample code. I have now mastered the ILI93xx series displays.

Everything you need to know is in all of these posts and reading all of them if you are here will teach you something things about displays you probably didnt know when you started all of this and will help you on the next one.

In short. No matter what any website says. A lot of these displays are NOT 5V displays. Not on ANY of the pins. ebay lies. Kenjutsu above me just posted the same thing. He is correct.

You will need a logic converter. I built a small one on a proto type board with a header to plug and unplug my display and it works really nice. You WILL need to build one of these.

Other than that my biggest set back was that some libraries reference pins 4,5 and 6 and some 8,9 and 10. and where LED goes and why why why....

This are USER definable. read the posts. From what I have read most all of them want the following

These are predefined in the Audrino hardware

sclk= 13
miso = 12 (This one really isn't used but mine doesn't seem to work without it)
mosi = 11

These are movable

d/c= 6
cs = 5
reset = 4

This one is preference. The led needs power. You can try hooking it directly to 3.3v or using pin 7 which in the test code uses PWM to drive the voltage. If you use pin 7, you can control on/off if you use directly the backlight will always be on. Some say use a resistor. I did both. didnt seem to matter.

LED= 7

Rinky dink electronics has a working library for these.

http://www.rinkydinkelectronics.com/library.php

The README file says exactly like above. It does work.

The Adafruit library also works well with the following

graphictest.ino, demo code in Adafruit library

#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9340.h"

#define _sclk 13
#define _miso 12
#define _mosi 11
#define _cs 5 //10
#define _dc 6 //9
#define _rst 4 //8

Adafruit_ILI9341 tft = Adafruit_ILI9341(_cs, _dc, _rst); // Use hardware SPI

So as you can see you can re-define cs, dc and rst to what you have. This goes the same for the Mega2650. They also work just fine there too.

I will also note the other issue I ran into. These displays can use either software or hardware SPI. You want to use hardware. Software driven re-defines the pin code through the software. It is 10 times slower. The adafruit library even says that.

// Using software SPI is really not suggested, its incredibly slow
//Adafruit_ILI9340 tft = Adafruit_ILI9340(_cs, _dc, _mosi, _sclk, _rst, _miso);

I ran my pin7 LED through the logic converter cause it was already wired on the proto board I made that way. running for 2 days now non-stop no problems.

Thank all of you for your posts, this is by far the longest form I have read and stayed at a while.

I attached a photo of my logic board. This cleared up 80 percent of my problems over using a breadboard. That is a TI 74LVC245AN logic converter. I got a handful off ebay for 7 bucks.

You will have to read the spec sheet but the connection is pretty straight forward. I went with that model so it would work inline on a proto breadboard with little wiring and look nice. The display mounts backwards over the whole mess so it looks like a somewhat made factory item when connected and I can use others with the same pinouts just by plugging in.

You can also look at the following post for info on driving the backlight via PWM:

PWM ILI9341 backlight control?

I have a problem. Nothing happens with the display except I cant turn on the backlight with connecting LED pin to voltage. :slight_smile:

So parts that I'm using.

Converter:
http://www.ebay.com/itm/281619636885

LCD:
http://www.ebay.com/itm/2-4-320-240-TFT-LCD-Touchscreen-with-PCB-ILI9341-Display-CP11023-/281725377549?hash=item4198241c0d

and Arduino Mega 2560 board.

So the wiring follows.

From arduino

3.3v goes to the Converter's 3.3v on the low side and also to LCD VVC pin.
GND goes to the Converter's GND pin on the low side and also to LCD GND pin.

Then all the wiring is thru converter except the MISO which is direct to arduino. All others go from arduino to Converters High pin and then from Low to LCD pin. For each wire seperate High and low ofcourse.

So:

CS 10
DC 9
RST 8

MOSI 51
SCK(SCLK) 52
MISO 50 (direct to arduino)

I don't know about LED. I put it on 3.3v but as I know it doesn't really matter?!?

So as far as I know wiring is correct?!

Can you tell me which code (library) to run. exemple. I have so many different libraries and none of them works.

Thanks

Anyone is using Dragino Yun shield ?

I want to connect it to 2.2 TFT screen

the screen is working when i use arduino uno to connect

but when uno + dragino yun, the connection is not working, i search document on web, someone suggest me to use ICSP pin, but it is still don't work

anyone can help?

xxtilenxx:
I have a problem. Nothing happens with the display except I cant turn on the backlight with connecting LED pin to voltage. :slight_smile:

So parts that I'm using.

Converter:
http://www.ebay.com/itm/281619636885

LCD:
http://www.ebay.com/itm/2-4-320-240-TFT-LCD-Touchscreen-with-PCB-ILI9341-Display-CP11023-/281725377549?hash=item4198241c0d

and Arduino Mega 2560 board.

So the wiring follows.

From arduino

3.3v goes to the Converter's 3.3v on the low side and also to LCD VVC pin.
GND goes to the Converter's GND pin on the low side and also to LCD GND pin.

Then all the wiring is thru converter except the MISO which is direct to arduino. All others go from arduino to Converters High pin and then from Low to LCD pin. For each wire seperate High and low ofcourse.

So:

CS 10
DC 9
RST 8

MOSI 51
SCK(SCLK) 52
MISO 50 (direct to arduino)

I don't know about LED. I put it on 3.3v but as I know it doesn't really matter?!?

So as far as I know wiring is correct?!

Can you tell me which code (library) to run. exemple. I have so many different libraries and none of them works.

https://youtu.be/hpe-mHnpw9M

Thanks

MISO (Master In Slave out) is not needed, since the LCD is not transferring nothing back to the arduino.

Double check that the reset pin is high (3.3V) otherwise just attach it to 3.3V.

You may have a faulty display as well. Its seems odd no library works. I would recommend mine, but it's uno only.

As to hardware, I'm not an apologist of using buffers. Buffers and breadboards are quite a big issue and added complexity for 4/8Mhz SPI signals. What i do is to modify the arduino to run at 3.3V and just connect the LCD directly. Everything stays the same, except the 5V pin has 3.3V on it and the output logical levels are 0 and 3.3V, rather than 0 and 5V. Search the internet for this mod if you want to try. Ill probably do a video at some point, just unfortunately i don't have any more boards to mod.

calvinchoi:
Anyone is using Dragino Yun shield ?

I want to connect it to 2.2 TFT screen

the screen is working when i use arduino uno to connect

but when uno + dragino yun, the connection is not working, i search document on web, someone suggest me to use ICSP pin, but it is still don't work

anyone can help?

Perhaps your shield is sharing one of the lines used for CS, DC or RST? I would do a check with a multimeter to make sure the pins you selected are free and not being shared with something else