Monday, July 27, 2015

2.2 or 2.4 or 2.8 inch SPI TFT LCD ILI9341 to Arduino Uno

Over the weekend I figured out how to interface a 2.8 inch SPI TFT that has a ILI9341 chip to an Arduino Uno.  All it takes is eight 1K resistors.  Most people use a 4050 IC.  Here is the schematic.

I am using the Adafruit ILI9341 driver found at:
Note that the Adafruit LCD has level shifters for 5 volts built into it.

Here is a video of it working on Youtube.

Here is a video of the LCD being used as an oscilloscope.

Here are a couple of still pictures, only 6 of the 8 bits are connected for these pictures.

Here is the code for a more basic oscilloscope.

 2.8 SPI PIND TFT Oscope Simple
 Reads the D0-D7 pins using PIND,
 and shows the value on the screen.
 Created 27 july 2015 by Bob Davis
//#include  // Arduino LCD library
#include "Adafruit_ILI9341.h"
#include "Adafruit_GFX.h"

// pin definition for the Uno LCD
#define TFT_DC 9
#define TFT_CS 10
// Use hardware SPI (on Uno, #13=clk, #11=mosi) and the above for CS/DC
//Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
Adafruit_ILI9341 tft = Adafruit_ILI9341();

//// set up variables
int Input=0;
byte Sample[320];
int trigger=64;

void setup(){
  // initialize rotate and clear the display
  // Set the font size
  // D input pins
  pinMode(0, INPUT);
  pinMode(1, INPUT);
  pinMode(2, INPUT);
  pinMode(3, INPUT);
  pinMode(4, INPUT);
  pinMode(5, INPUT);
  pinMode(6, INPUT);
  pinMode(7, INPUT);

void loop(){
  // wait for a positive going trigger
  for (int timeout=0; timeout < 1000; timeout++){
    Input = PIND;
    if (Input < trigger) break;  }
  for (int timeout=0; timeout < 1000; timeout++){
    Input = PIND;
    if (Input > trigger) break;  }
  // quickly collect the data with no delay
  for (int xpos=0; xpos <320; xpos++){
  // display the collected data
  for (int xpos=0; xpos <319; xpos++){
  // erase the old and draw new line
    tft.drawLine(xpos+1, 0, xpos+1, 240, ILI9341_BLACK);
    tft.drawLine(xpos, (Sample[xpos]*2), xpos+1, Sample[xpos+1]*2, ILI9341_WHITE);
// End of program

There is more info on the analog to digital converter at


Ralph Doncaster said...

The 50% resistor divider you created provides 2.5V to the LCD powered at 3.3V.
Using 1K and 560 Ohm would be a much closer match (3.2V to the LCD) and the increased drive strength would allow you to run the LCD communications at higher speeds.

Bob Davis said...

Using a 1K and a 2K resistor would also work. However the driver IC is actually rated to run on 2.5 volt or 3 volt logic so 2.5 volts works fine.

Yullo said...

Hi, I used your schematic for my project and it works perfectly.
Than you !

Mohd Rafiq said...


At the pinmode. What should i put on the input? Or is it just a copy and paste and it should work fine?

Curtis Newton said...

that code makes no sense and is flooded with errors/typos

Bob Davis said...

It is tricky to get code to display correctly on blogspot.

Bob Davis said...

There is an extra "include" just delete it.