Let's Make Robots! | RobotShop

How to use 2.4inch TFT LCD SPFD5408 with arduino MEGA 2560

Interface an lcd tft screen with arduino

Some of you may have purchased this LCD Screen or thinking of getting one. Its a great screen for displaying images and graphics. I purchased mine for displaying sensor data from my 10 sensors on my robot via xbee (telemetry). I bought it not only out of impulse as it was very cheap but also that it was the biggest screen i could find cheaply in Australia. ($15).

Enough of me rambling...

Unfortunately this LCD Screen has not much support and i have seen people unable to find libraries for it especially for the MEGA.


1.I used the SWIFT Library and the Adafruit GFX Library

SWIFT Library by smoke and wires:

Smoke and wires lcd tutorial

AdaFruit GFX Library

2.After copying the libraries over to your libraries folder, open the SWIFT folder, locate SWIFT.cpp and change this line from

<code>// Use the include which corresponds to your arduino
//#include "mega_24_shield.h"
#include "uno_24_shield.h"<code>

to this (just un-comment the mega part and comment the uno part.

<code>// Use the include which corresponds to your arduino
#include "mega_24_shield.h"
//#include "uno_24_shield.h"<code>

This will allow you to use the screen on the arduino MEGA. In terms of the connections from the screen to the mega, just plug it in like a shield the same way as you do when connecting it to the UNO.

Here is a simple code sample i wrote just to display text in landscape mode. (its not the best code)

<code>// Code provided by Smoke And Wires
// http://www.smokeandwires.co.nz
// This code has been taken from the Adafruit TFT Library and modified
//  by us for use with our TFT Shields / Modules
// For original code / licensing please refer to
// https://github.com/adafruit/TFTLCD-Library

#include <Adafruit_GFX.h>    // Core graphics library
#include "SWTFT.h" // Hardware-specific library

// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
// #define LCD_CS A3 // Chip Select goes to Analog 3
// #define LCD_CD A2 // Command/Data goes to Analog 2
// #define LCD_WR A1 // LCD Write goes to Analog 1
// #define LCD_RD A0 // LCD Read goes to Analog 0

// #define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
//   D0 connects to digital pin 8  (Notice these are
//   D1 connects to digital pin 9   NOT in order!)
//   D2 connects to digital pin 2
//   D3 connects to digital pin 3
//   D4 connects to digital pin 4
//   D5 connects to digital pin 5
//   D6 connects to digital pin 6
//   D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).

// Assign human-readable names to some common 16-bit color values:
#define    BLACK   0x0000
#define    BLUE    0x001F
#define    RED     0xF800
#define    GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0
#define WHITE   0xFFFF

SWTFT tft;
// If using the shield, all control and data lines are fixed, and
// a simpler declaration can optionally be used:
// SWTFT tft;

void setup(void) {

  uint16_t identifier = tft.readID();

void loop(void) {
  for(uint8_t rotation=0; rotation=1; rotation++) {

unsigned long testFillScreen() {
  unsigned long start = micros();
  return micros() - start;

unsigned long testText() {
  unsigned long start = micros();
  tft.setCursor(0, 0);
  tft.setTextColor(WHITE);  tft.setTextSize(1);
  tft.println("Bobs Robotics!");

  tft.println("Motor temp ~56 degrees C");

  tft.println("ESC Temp ~50 degrees C");

  tft.println("Methane Sensor ~20ppm");

  tft.println("Hydrogen sensor~0.2ppm");

  tft.println("Co2 Sensor ~70ppm");

  tft.println("Air pressure ~100011Pa");

  tft.println("Current temp ~30 degrees C");

  tft.println("Current Humidity is 50%");

  tft.println("Altutude ~45m");

  tft.println("Voltage remaining ~ 7.6V");

  tft.println("Current draw ~12A");
  tft.println("UV Index is 12mW/cm^2");
  tft.println("light intensity is 930Lux");

  return micros() - start;


here is an image of it


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Hey thanks for making this. I just got mine in mail today.

I too bought it from.ebay on a spur it was cheap.

Any other applications you have planned?

My main objective is to get the screen working with getting wireless telemetry at the moment :)

Where in the land of AUS did you find the cheap supply of this screen. Many of us here woudl like to know ... I am over searching for cost effective screens!!

I got mine on ebay for $15. in China they are half that!

I got mine from ebay. Cost was I believe 6$.

Can someone advise me how to use this with arduino.uni 

and also.with working code for this program. I want to have the temp display as this poster does.

Hi ..... thanks forsharing this info.

my project is smart meter so i used voltage and cuurent sensors and liquid crystal lcd  .... now i decided to use this TFT LCD whith arduino MEGA .... can you give me more info on that ..  i tried whith many libraries .. no think work ... just white screen !!!!

hi >> i teat the code and it gave mirror display (inverted cordenates )