Introduction: Cheap TFT 2.2 Inch Display on Arduino (ILI9340C or ILI9341)
I ordered a 240 x 320 pixel 2.2 inch TFT LCD display off of ebay for £3.86 which is dirt cheap compared to similar displays from some of the western companies. The only problem was that there wasn't a guide to how to get it working! When I figured it out I thought I'd make an Instructable for anyone with the same issues. It actually turned out to be quite simple. This tutorial doesn't show you how to use the SD card functionality.
A couple of users have complained that I am using adafruit libraries and I am not supporting adafruit. I'd like to point out that adafruit provide their libraries under The MIT License, which amoungst other things says:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute...
You can look up the entire license if you are interested.
I understand this to mean that adafruit are perfectly happy for their code to be edited to drive cheap chinese displays, and there is no point going to the effort of writing my own code to drive it. If you have an issue with the ethics, I'd like to point out that my behavior is perfectly legal so please keep your rant elsewhere. Thankyou.
Step 1: Parts List
2.2" Serial 240x320 SPI TFT LCD Module Display ILI9340C
An Arduino compatible microcontroler - I use a Breadboard Arduino
Something to convert to 3.3V logic - I power my breadboard Arduino with 3.3V
My setup is a little like this although I ordered my components separately.
Step 2: Install the Correct Libraries
Luckily for us, Adafruit have a very similar display that they have written libraries for. I have the display which is powered by the ILI9340 driver so I installed that library so I assume if you have a display with the ILI9341 driver it works exactly the same with the other library that I linked. I haven't seen any other drivers used but if you do, I recommend searching the Adafruit libraries on github.
You also need to install the Adafruit GFX library regardless of what driver the display uses.
Instructions on how you do this are on the github pages linked.
My arduino IDE updated and it didn't like having hyphens/underscores in folder names of libraries. If you are getting an error message complaining about these characters try removing them from the folder names (but not the names of the .h and .cpp files).
Step 3: Wire It Up and Upload the Example Sketch
There is an example sketch included with the ILI9340/1 library called graphics test. You have to wire the display up in accordance to the pin definitions there.
Originally When I wrote this Instructable I wrote:
I'd like to emphasize that this display uses 3.3V logic, and will not work if you use 5V. This is information that I found on some forum somewhere and using it I got my display to work
I now have multiple of these displays from different sellers (and perhaps different factories). I have noticed that some of them also behave using 5V logic.
As labeled on my display module, the connections are
SCK - Arduino Pin 13
SDO(MISO) - Arduino Pin 12
SDI(MOSI) - Arduino Pin 11
CS - Arduino Pin 10
D/C - Arduino Pin 9
RESET - Arduino Pin 8
LED - 3.3V / 5V
VCC - 3.3V / 5V
GND - GND
Upload the example sketch and give it a go, the sketch shows you well how to control the display.
You may have to fiddle with the voltages for your particular model. There are various options you have here -potential dividers on each pin, level shifters, or simply powering your arduino with a 3.3v supply (this is perhaps the hackiest and can be slightly temperamental). See the comments for details.
Also, there is information about how to use the library on adafruits website.
A datasheet can be found here
You may do what you like with this Instructable, without having to contact me first.
6 People Made This Project!
We have a be nice policy.
Please be positive and constructive.