SPI controlled TFT display

Normal Arduino SPI TFT display library does not work with cheap TFT displays with integrated ILI9340C controller chip. Display model is TM022HDH26. Hopefully there is two libraries made by Adafruit that works together and brings display to live. Those are easy to install from Arduino IDE Library Manager. Needed libraries are Adafruit GFX Library and Adafruit_ILI9340. Result is below.

Arduino connection
  • SCLK (Serial Clock) to pin D13
  • MOSI (Master Output → Slave Input) to pin D11
  • CS (Chip Select) to pin D10
  • D/C (Data/Control) to pin D9
  • Reset to pin D8

Simple example code for testing.

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

// pin definition
const byte CS = 10;
const byte DC = 9;
const byte RS = 8;

Adafruit_ILI9340 scr = Adafruit_ILI9340(CS, DC, RS);

void setup() {
  scr.begin();
  scr.fillScreen(ILI9340_BLACK);
  scr.setTextColor(ILI9340_RED);
  scr.setTextSize(3);
  scr.println("Juvar's");
  scr.setTextSize(2);
  scr.println("Electronics Corner");
  scr.setTextColor(ILI9340_WHITE);
  scr.setTextSize(1);
  scr.println("All kinds of electronics");
  scr.println();
  scr.setTextColor(ILI9340_YELLOW);
  scr.setTextSize(2);
  scr.println("Testing display with");
  scr.println("ILI9340C controller.");
}

void loop() {
  // nothing here
}

 

Leave a Reply