We've written a full graphics library specifically for this display which will get you up and running quickly. The code is written in C/C++ for Arduino but is easy to port to any microcontroller by rewritting the low level pin access functions. Here are some of the functions we've included in the library.
The TFT LCD library is based off of the Adafruit GFX graphics core library. GFX has many ready to go functions that should help you start out with your project. Its not exhaustive and we'll try to update it if we find a really useful function. Right now it supports pixels, lines, rectangles, circles, round-rects, triangles and printing text as well as rotation.Read more about it here!
In this example, we'll show how to display a 220x176 pixel full color bitmap from a microSD card.
We have an example sketch in the library showing how to display full color bitmap images stored on an SD card. You'll need a microSD card such as this one
. You'll also need to be running Arduino 1.0 or later, as the SD library was updated.
You'll also need an image. We suggest starting with this bitmap of a rose
. If you want to later use your own image, use an image editing tool and crop your image to no larger than 160 pixels high and 128 pixels wide. Save it as a 24-bit color BMP
file - it must be 24-bit color format to work, even if it was originally a 16-bit color image - becaue of the way BMPs are stored and displayed!
Names for bitmap files must not exceed 8 characters with a 3 character extension
. "mybitmap.bmp" is fine. "myotherbitmap.bmp" is too long and will not be readable by the SD file system.
Copy the rose.bmp
to the microSD card and insert it into the back of the breakout board.
Wire up the TFT according to the high-speed SPI diagram above. Test that your wiring is correct by uploading the graphics test sketch with the high speed SPI line uncommented and the flexible-low-speed wiring commented.
Once you are sure that the TFT is wired correctly, add the two wires for talking to the SD card. Connect CDCS (the unconnected pin in the middle) to digital pin 4 (you can change this later to any pin you want) that's the orange wire below. Connect MISO (last unconnected pin) to the Arduino's hardware SPI MISO pin, that's the white wire below. For Classic arduinos, this is pin 12. For Mega's this is pin 50. You can't change the MISO pin, its fixed in the chip hardware.
Now load the bitmap example sketch into the Arduino. It should display the parrot image. If you have any problems, check the serial console for any messages such as not being able to initialize the microSD card or not finding the image.
This guide was first published on Aug 29, 2012. It was last
updated on Aug 29, 2012.
This page (Adafruit GFX Library) was last updated on Dec 22, 2017.