The Board

ILI9341 TFT Touch Screen

       

Connecting Up The TFT

For this project We used a 2.4" 240 x 320 TFT Touch screen with SD Card holder. The first phase of the is project is to try out the colour display. We can use a 3.3V 8MHz Arduino Pro Mini to drive the display. 

Pin Connections

Pins 1 - 5 are for the touch screen and we will add these connections to this page once I have tried it out.

Pin Connections
ILI9341Pin NameArduinoMega 2560
1T_IRQ
2T_DO
3T_DIN
4T_CS
5T_CLK
6SDO(MISO)1250
7LEDVCCVCC
8SCK1352
9SDI(MOSI)1151
10D/C946
11RESET848
12CS1053
13GNDGNDGND
14VCCVCCVCC

Code

First you need to download and install these two libraries from ADAFruit:

Then, in the Arduino IDE, open the 'graphicstest' example, which is in the ILI9341 library examples folder. The code says that the reset is optional, but, as before, we had to enable it to get my display to work.

So, add line 22 which defines the RESET Pin number and edit line 27 to add the RESET Pin parameter.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/***************************************************
  This is our GFX example for the Adafruit ILI9341 Breakout and Shield
 
  Check out the links above for our tutorials and wiring diagrams
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional)
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!
 
  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/
 
 
#include "SPI.h"
#include "Adafruit_GFX.h"
#include "Adafruit_ILI9341.h"
 
// For the Adafruit shield, these are the default.
#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10
 
// Use hardware SPI (on Uno, #13, #12, #11) and the above for CS/DC
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
// If using the breakout, change pins as desired
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_MOSI, TFT_CLK, TFT_RST, TFT_MISO);

Video Demonstration

Adding SD Card Reading

Pin Connections

I have used Pin 4 for SD_CS (Chip Select). This is configurable in the code

Pin Connections
ILI9341Pin NameArduino
1SD_CS4
2SD_MOSI11
3SD_MISO12
4SD_SCK13

The Card

Code

You must complete the first section so you will have downloaded and installed these two libraries from ADAFruit:

Then, in the Arduino IDE, open the 'spitftbitmap' example, which is in the ILI9341 library examples folder. The code says that the reset is optional, but, as above, I had to enable it to get my display to work.

So, add line 22 which defines the RESET Pin number and edit line 27 to add the RESET Pin parameter. Then change line 46 to match the name of your bitmap file.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/***************************************************
  This is our Bitmap drawing example for the Adafruit ILI9341 Breakout and Shield
 
  Check out the links above for our tutorials and wiring diagrams
  These displays use SPI to communicate, 4 or 5 pins are required to
  interface (RST is optional)
  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!
 
  Written by Limor Fried/Ladyada for Adafruit Industries.
  MIT license, all text above must be included in any redistribution
 ****************************************************/
 
 
#include <Adafruit_GFX.h>    // Core graphics library
#include "Adafruit_ILI9341.h" // Hardware-specific library
#include <SPI.h>
#include <SD.h>
 
// TFT display and SD card will share the hardware SPI interface.
// Hardware SPI pins are specific to the Arduino board type and
// cannot be remapped to alternate pins.  For Arduino Uno,
// Duemilanove, etc., pin 11 = MOSI, pin 12 = MISO, pin 13 = SCK.
 
#define TFT_RST 8
#define TFT_DC 9
#define TFT_CS 10
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC, TFT_RST);
 
#define SD_CS 4
 
void setup(void) {
  Serial.begin(9600);
 
  tft.begin();
  tft.fillScreen(ILI9341_BLUE);
   
  Serial.print("Initializing SD card...");
  if (!SD.begin(SD_CS)) {
    Serial.println("failed!");
  }
  Serial.println("OK!");
 
  bmpDraw("i.bmp", 0, 0);
}

Serial Monitor Output

Serial Monitor Output

Video Demonstration

Links