Displaying Bitmaps

In this example, we'll show how to display a 128x160 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 download our SD library modified to allow faster reads (these changes will hopefully be added to arduino v23) but for now you can download the new library here. Download the library by clicking the Downloads button and uncompressing the folder. Replace the files in yourArduinoIDE/libraries/SD folder (make a backup of course) and restart the IDE.

You'll also need an image. We suggest starting with this bitmap of a parrot. 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!

Copy the parrot.bmp to the microSD card and insert it into the micro SD card holder on your shield or breakout board.

Breakout Wiring

Shield users can skip directly to the "Example Sketch" section.

Wire up the TFT as described on the wiring & test page. Test that your wiring is correct by uploading the graphics test sketch with the high speed SPI lines.

Once you are sure that the TFT is wired correctly, add the two wires for talking to the SD card. Connect CARD_CS (the unconnected pin in the middle) to digital pin 4 (you can change this later to any pin you want). Connect MISO (second from the right) to the Arduino's hardware SPI MISO pin. 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.

Example Sketch

Load the spitftbitmap example sketch into the Arduino IDE.

Breakout
and Shield on an Arduino Uno users can use the code as-is.

Now upload the spitftbitmap example sketch to 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 (Displaying Bitmaps) was last updated on Nov 11, 2018.