Before you start, we'll need to tell the display to put us in SPI mode so it will know which pins to listen to. To do that, we have to connect tbe IM1, IM2 and IM3 pins to 3.3V. The easiest way to do that is to solder closed the IMx jumpers on the back of the PCB. Turn over the PCB and find the solder jumpers
Wiring up the display in SPI mode is much easier than 8-bit mode since there's way fewer wires. Start by connecting the power pins
- 3-5V Vin connects to the Arduino 5V pin
- GND connects to Arduino ground
- CLK connects to SPI clock. On Arduino Uno/Duemilanove/328-based, thats Digital 13. On Mega's, its Digital 52 and on Leonardo/Due its ICSP-3 (See SPI Connections for more details)
- MISO connects to SPI MISO. On Arduino Uno/Duemilanove/328-based, thats Digital 12. On Mega's, its Digital 50 and on Leonardo/Due its ICSP-1 (See SPI Connections for more details)
- MOSI connects to SPI MOSI. On Arduino Uno/Duemilanove/328-based, thats Digital 11. On Mega's, its Digital 51 and on Leonardo/Due its ICSP-4 (See SPI Connections for more details)
- CS connects to our SPI Chip Select pin. We'll be using Digital 10 but you can later change this to any pin
- D/C connects to our SPI data/command select pin. We'll be using Digital 9 but you can later change this pin too.
You'll need a few libraries to use this display
From within the Arduino IDE, open up the Library Manager...
We have example code ready to go for use with these TFTs.
Two libraries need to be downloaded and installed: first is the Adafruit ILI9341 library (this contains the low-level code specific to this device), and second is the Adafruit GFX Library (which handles graphics operations common to many displays we carry). If you have Adafruit_GFX already, make sure its the most recent version since we've made updates for better performance
Search for ILI9341 and install the Adafruit ILI9341 library that pops up!
For more details, especially for first-time library installers, check out our great tutorial at http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use
Next up, search for Adafruit GFX and locate the core library. A lot of libraries may pop up because we reference it in the description so just make sure you see Adafruit GFX Library in bold at the top.
If using an older Arduino IDE (pre-1.8.10), also locate and install Adafruit_BusIO.
If you did not connect up the MISO line to the TFT, you wont see the read configuation bytes so please make sure you connect up the MISO line for easy debugging! Once its all working, you can remove the MISO line