# 2.8" TFT Touchscreen

## Overview

Info: 

![](https://cdn-learn.adafruit.com/assets/assets/000/003/024/medium800/lcds___displays_testbars1.jpg?1396790404)

Add some jazz & pizazz to your project with a color touchscreen LCD. This TFT display is big (2.8" diagonal) bright (4 white-LED backlight) and colorful (16-bit 262,000 different shades)! 240x320 pixels with individual pixel control, this has way more resolution than a black and white 128x64 display. As a bonus, this display has a resistive touchscreen attached to it already, so you can detect finger presses anywhere on the screen.![](https://cdn-learn.adafruit.com/assets/assets/000/003/025/medium800/lcds___displays_28tfttouchbreakoutwoof_LRG.jpg?1396790412)

This display has a controller built into it with RAM buffering, so that almost no work is done by the microcontroller. You'll need 8 digital data lines and 4 or 5 digital control lines to read and write to the display (12 lines total). 4 pins are required for the touch screen (2 digital, 2 analog) but because of the way resistive touch screens work, we can share pins with the LCD so the entire setup can be run by 12 pins (10 digital, 2 analog).  
  
Of course, we wouldn't just leave you with a datasheet and a "good luck!" - [we've written a full open source graphics library that can draw pixels, lines, rectangles, circles and text](https://github.com/adafruit/TFTLCD-Library) . We[also have a touch screen library that detects x, y and z (pressure)](https://github.com/adafruit/Touch-Screen-Library) and example code to demonstrate all of it. The code is written for Arduino but can be easily ported to your favorite microcontroller!  
  
 **[Pick one up today at the Adafruit Shop!](http://www.adafruit.com/index.php?main_page=product_info&cPath=37&products_id=335)**  
  
**Specifications:**
- 2.8" diagonal LCD TFT display
- 240x320 resolution, 16-bit (262,000) color
- [ILI9325 (datasheet)](http://www.adafruit.com/datasheets/ILI9325.pdf) or [ILI9328 (datasheet)](http://www.adafruit.com/datasheets/ILI9328.pdf) controller with built in video RAM buffer
- 8 bit digital interface, plus 4 or 5 control lines
- 5V compatible! Use with 3.3V or 5V logic
- Onboard 3.3V @ 150mA LDO regulator
- 4 white LED backlight, transistor connected so you can PWM dim the backlight
- 1x20 header for easy breadboarding, or 2x10 header for cable connection
- 4 x 0.125"/3mm mounting holes with tabs
- 4-wire resistive touchscreen

![](https://cdn-learn.adafruit.com/assets/assets/000/003/026/medium800/lcds___displays_headerready.jpg?1396790423)

![](https://cdn-learn.adafruit.com/assets/assets/000/003/027/medium800/lcds___displays_tftbackv.jpg?1396790433)

 **This guide is specifically for the TFT LCD** <u><b>breakout board</b></u> **. There's a** [**separate tutorial for the Arduino shield**](http://learn.adafruit.com/2-8-tft-touch-shield) **version of this display.**  
# 2.8" TFT Touchscreen

## Connection Options

Info: 

The TFT LCD requires a lot of pins to use with your processor. We have two breakouts available which you can use depending on your application.![](https://cdn-learn.adafruit.com/assets/assets/000/003/028/medium800/lcds___displays_tftbackh.jpg?1396790440)

The first (right hand side) is a single 1x20 header strip with 0.1" spacing. This is perfect for breadboard use or if you have to do some hand wiring. You can use 'straight' header or 'right angle' header so that it stands up straight (although it may be harder to touch if its soldered this way).  
  
To solder the header, we suggest placing a 20pin strip of header, long pins down into a breadboard.  
![](https://cdn-learn.adafruit.com/assets/assets/000/003/029/medium800/lcds___displays_headerplace.jpg?1396790449)

Place the LCD on top and solder each pin.![](https://cdn-learn.adafruit.com/assets/assets/000/003/030/medium800/lcds___displays_headersolder.jpg?1396790458)

![](https://cdn-learn.adafruit.com/assets/assets/000/003/031/medium800/lcds___displays_soldered.jpg?1396790468)

The second is a 2x10 dual header strip with 0.1" spacing. This is perfect for use with an IDC cable for remote access. We suggest a 6" cable but you might be able to use a 12" one, it depends on how fast you're writing to the screen (faster means a shorter cable required).![](https://cdn-learn.adafruit.com/assets/assets/000/003/032/medium800/lcds___displays_10condjumper.jpg?1396790479)

_This cable is a 2x5 not 2x10 but its what the larger cable will look like_  
  
[You can pick up a socket-socket cable from digikey for $2 - they're also available from any other electronics shop](http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=H3AAH-2006G-ND).  
# 2.8" TFT Touchscreen

## Mounting Options

Info: 

We wanted to make sure that you could easily put this display in a box. There are four mounting holes on tabs. If you really don't need the tabs they can be cut off with a hacksaw or tin-snips. The holes are 2.25" apart in the short direction and 2.95" apart in the long direction. The drill holes are 0.125" and will easily take a #4 imperial or M3 (3mm) screw. The PCB is 0.063" thick.# 2.8" TFT Touchscreen

## Backlight Wiring

Info: 

There are three basic 'components' to the LCD.  
  
The backlight is the first. It is made of 4 white LEDs in parallel with a transistor to control them. The LEDs can draw as much as 80mA all together, but you can PWM the backlight to dim it - the transistor makes it easy to connect any kind of microcontroller output. You can also connect the backlight pin directly to a 3 or 5V pin to turn it on all the way.  
  
We'll begin by assuming you'll be using the 1x20 connector and an Arduino. Wiring may be different for your microcontroller.  
  
Start by connecting the first pin **Ground** of the LCD to ground and the second pin **3-5V** to 5V (you can use 3-5V, this pin will power the TFT and backlight so be sure it can supply 100mA). Then skip 5 pins and connect pin #8 **Backlite** to 5V.  
![](https://cdn-learn.adafruit.com/assets/assets/000/003/033/medium800/lcds___displays_powerwire.jpg?1396790486)

Power up your set, and you'll see the 4 white LED backlight. If this isn't working, something is amiss with your power supply. Go back and fix the wiring!![](https://cdn-learn.adafruit.com/assets/assets/000/003/034/medium800/lcds___displays_backlightest.jpg?1396790494)

# 2.8" TFT Touchscreen

## TFT Wiring

Info: 

Now that the backlight is working, we can get the TFT LCD working. There are many pins required, and to keep the code running fairly fast, we have 'hardcoded' Arduino digital pins #2-#9 for the 8 data lines.  
  
Start at the end of the TFT (other side than the power pins) and in order connect the pins to digital 7 thru 2. If you're using a mega, connect the TFT Data Pins #0-7 to Mega pins #22-29, in that order. Those Mega pins are on the 'double' header.  
![](https://cdn-learn.adafruit.com/assets/assets/000/003/035/medium800/lcds___displays_datahigh.jpg?1396790504)

Then connect the next two pins to digital 9 and 8.  
  
If you're using a mega, connect the TFT Data Pins #0-7 to Mega pins #22-29, in that order. Those Mega pins are on the 'double' header.

![](https://cdn-learn.adafruit.com/assets/assets/000/003/036/medium800/lcds___displays_datalow.jpg?1396790514)

In addition to the 8 data lines, you'll also need 4 or 5 control lines.

- Connect the third pin **CS** ( **Chip Select** ) to Analog 3
- Connect the fourth pin **C/D** ( **Command/Data** ) to Analog 2
- Connect the fifth pin **WR** ( **Write** ) to Analog 1
- Connect the sixth pin **RD** ( **Read** ) to Analog 0
- Connect the seventh pin **RST** ( **Reset** ) to the Arduino Reset line. This will reset the panel when the Arduino is Reset. You can also use a digital pin for the LCD reset but this will save us a pin.

![](https://cdn-learn.adafruit.com/assets/assets/000/003/037/medium800/lcds___displays_controlwire.jpg?1396790524)

Now we can run some code!# 2.8" TFT Touchscreen

## LCD Test

Danger: 

We have example code ready to go for use with these TFTs. It's written for Arduino, which should be portable to any microcontroller by adapting the C++ source.  
  
_Two_ libraries need to be downloaded and installed: the [TFTLCD library](https://github.com/adafruit/TFTLCD-Library) and the [GFX library.](https://github.com/adafruit/Adafruit-GFX-Library) You can install these libraries through the Arduino library manager.

Open up the Arduino library manager:

![](https://cdn-learn.adafruit.com/assets/assets/000/084/235/medium800/graphic_lcds_library_manager_menu.png?1573778702)

Search for the&nbsp; **Adafruit GFX** library and install it

![](https://cdn-learn.adafruit.com/assets/assets/000/084/236/medium800/graphic_lcds_gfx.png?1573778766)

Search for the&nbsp; **Adafruit TFTLCD&nbsp;** library and install it

![](https://cdn-learn.adafruit.com/assets/assets/000/086/809/medium800/graphic_lcds_tftlcd.png?1578606514)

If using an older version of the Arduino IDE (pre-1.8.10), also locate and install the **Adafruit\_BusIO** library (newer versions do this automatically when using the Arduino Library Manager).

We also have a great tutorial on Arduino library installation at:  
[http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use](http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use "Link: http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use")

In the TFTLCD Library folder, you will need to edit TFTLCD.h. On about line 12, you will see **"#define USE\_ADAFRUIT\_SHIELD\_PINOUT"**. Comment out this line and save the file.  
  
After restarting the Arduino software, you should see a new **example** folder called **Adafruit\_TFTLCD** and inside, an example called **graphicstest**. Upload that sketch to your Arduino. You may need to press the Reset button to reset the arduino and TFT. You should see a collection of graphical tests draw out on the TFT.

![](https://cdn-learn.adafruit.com/assets/assets/000/003/038/medium800/lcds___displays_bluelines.jpg?1396790532)

![](https://cdn-learn.adafruit.com/assets/assets/000/003/039/medium800/lcds___displays_purplecircles.jpg?1396790539)

![](https://cdn-learn.adafruit.com/assets/assets/000/003/040/medium800/lcds___displays_testbars1.jpg?1396790550)

Now you know everything is working. If you're having problems, check the serial port monitor. The first thing the sketch does is read the driver code from the TFT. It should be **0x9328** or **0x9325** so if you see something like **0x8328** that means that the D8 pin is not wired correctly and if you get **0x9228** then pin D0 is not wired correctly. Remember that the two bytes are read one after another.

# 2.8" TFT Touchscreen

## Graphics Library

Info: 

The graphics library has a few 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.  
  
First thing to note is that color is 16-bit, and that includes **Red, Green** and **Blue** in a 16-bit variable. The way the color is packed in is the top 5 bits are red, the middle 6 bits are green and the bottom 5 bits are blue.  
  
For solid colors, we have this handy cheat-sheet. Of course, you can pick any of 262,000 colors but while starting out, this might be helpful.  
```auto
// Color definitions
#define BLACK           0x0000
#define BLUE            0x001F
#define RED             0xF800
#define GREEN           0x07E0
#define CYAN            0x07FF
#define MAGENTA         0xF81F
#define YELLOW          0xFFE0 
 
#define WHITE           0xFFFF
```

The Adafruit GFX library is what draws all the dots, lines, shapes, and text. Its fairly detailed and has lots of cool stuff, for lots of info, check out [http://learn.adafruit.com/adafruit-gfx-graphics-library](http://learn.adafruit.com/adafruit-gfx-graphics-library "Link: http://learn.adafruit.com/adafruit-gfx-graphics-library")   
  
Here is a basic introduction to the GFX lib, it doesn't cover everything but it shows you what some of the most popular shapes look like  
  
First up is the most basic pixel pusher. You can call this with two coordinates and a color and it will make a dot:

```auto
void drawPixel(uint16_t x, uint16_t y, uint16_t color);
```

![](https://cdn-learn.adafruit.com/assets/assets/000/003/041/medium800/lcds___displays_lines.jpg?1396790555)

You can also draw lines, with a starting and end point and color.```auto
void drawLine(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color);
```

If your lines are vertical or horizontal, you can call an optimized drawing function that doesn't do all the angular calculations.```auto
void drawVerticalLine(uint16_t x0, uint16_t y0, uint16_t length, uint16_t color);
 
void drawHorizontalLine(uint16_t x0, uint16_t y0, uint16_t length, uint16_t color);
```

![](https://cdn-learn.adafruit.com/assets/assets/000/003/042/medium800/lcds___displays_rects.jpg?1396790565)

Next up, rectangles and squares can be drawn and filled using the following procedures. If you want a recangle that has a contrasting outline color,&nbsp; **fillRect** &nbsp;first, then&nbsp; **drawRect** &nbsp;over it.```auto
void drawRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t color);
 
void fillRect(uint16_t x0, uint16_t y0, uint16_t w, uint16_t h, uint16_t color);
```

![](https://cdn-learn.adafruit.com/assets/assets/000/003/043/medium800/lcds___displays_circles.jpg?1396790575)

Likewise, for circles, you can draw and fill.```auto
void drawCircle(uint16_t x0, uint16_t y0, uint16_t r,	uint16_t color);
 
void fillCircle(uint16_t x0, uint16_t y0, uint16_t r,	uint16_t color);
```

![](https://cdn-learn.adafruit.com/assets/assets/000/003/044/medium800/lcds___displays_text.jpg?1396790585)

Text is a little different. Instead of one procedure, you will set up the text size, color and location and then&nbsp;**print()**&nbsp;(just like Serial.print()!)```auto
void setCursor(uint16_t x0, uint16_t y0);
void setTextColor(uint16_t color);
 
void setTextSize(uint8_t size);
```

First start with **setCursor(x, y)** this will place the top right corner of the text where-ever you please. Initially, its set to (0, 0). Then set the text color with **setTextColor(color)** by default its white. Then set the 'size' with **setTextSize(size)** this will 'multiply' the text by a scaling factor. Above you can see scales of 1 (default), 2 and 3. This is because we only ship the library with a simple font, to save space. You can just scale it to get bigger text without requiring a new font.  
  
Finally, you can use **print()** or **println()** just like you do with **Serial**! For example, to print a string, use **print("Hello world")** - that's the first line of the image above. To print variables, you can also use **print()** the second line is**print(1234.56)** and the third line is **print(0xDEADBEEF, HEX)**.  
  
You can also rotate your drawing. Note that this will not rotate what you already drew, but it will relocate any new drawing.

![](https://cdn-learn.adafruit.com/assets/assets/000/003/045/medium800/lcds___displays_rotated.jpg?1396790591)

```auto
 void rotate(uint8_t rotation);
```

The rotation variable can be 0, 1, 2 or 3. Rotation 0 makes it so that the display is in portrait mode, with the USB jack in the top right. Rotation 2 is portrait, with the USB jack in the bottom left. Rotation 1 is landscape mode, with the USB jack in the bottom right and rotation 3 is also landscape, with the USB jack in the top left.  
  
When you rotate, the origin point moves with you. You may need to reference the size of the screen, which changes between portrait and landscape, use **width()** and **height()**! To get the size.  
```auto
uint16_t width(); 
uint16_t height();
```

These primitives should get you started!# 2.8" TFT Touchscreen

## Touchscreen

Danger: 

The LCD has a 2.8" 4-wire resistive touch screen glued onto it. You can use this for detecing finger-presses, stylus', etc. You'll need 4 pins to talk to the touch panel **but** you can **reuse** some of the pins for the TFT LCD! This is because the resistance of the panel is high enough that it doesn't interfere with the digital input/output and we can query the panel in between TFT accesses, when the pins are not being used.  
  
You can wire up the 4 remaining pins as follows. the one on the very left ( **Y-** orange) can connect to digital **9** , the next one over ( **X-** green) connects to **Analog 2** , The next one over ( **Y+** blue) connects to **Analog 3** and the last one ( **X+** gray) connects to digital **8**. The X- and Y+ pins pretty much have to connect to those analog pins (or to analog 4/5) but Y-/X+ can connect to any digital or analog pins.

![](https://cdn-learn.adafruit.com/assets/assets/000/003/046/medium800/lcds___displays_touchwire.jpg?1396790601)

# Download Library

Begin by opening up the Arduino library manager

![](https://cdn-learn.adafruit.com/assets/assets/000/084/057/medium800/graphic_lcds_library_manager_menu.png?1573528610)

Search for the&nbsp; **Adafruit TouchScreen** &nbsp;library and install it

![](https://cdn-learn.adafruit.com/assets/assets/000/084/058/medium800/graphic_lcds_touchscreen.png?1573528630)

We also have a great tutorial on Arduino library installation at:  
[http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use](http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use "Link: http://learn.adafruit.com/adafruit-all-about-arduino-libraries-install-use")

Now start up the **tftpaint** example in the Arduino library. The right hand side will have 'color boxes' you can press to select which color you want to draw with. If you press the area to the **left** where the screen ends, it will erase the screen.

![](https://cdn-learn.adafruit.com/assets/assets/000/003/047/medium800/lcds___displays_paint.jpg?1396790611)

You can use your fingertip to draw.![](https://cdn-learn.adafruit.com/assets/assets/000/003/048/medium800/lcds___displays_helloworld.jpg?1396790617)

![](https://cdn-learn.adafruit.com/assets/assets/000/003/049/medium800/lcds___displays_star.jpg?1396790626)

![](https://cdn-learn.adafruit.com/assets/assets/000/003/050/medium800/lcds___displays_heart.jpg?1396790636)

If you press the area to the **left** where the screen ends, it will erase the screen.

# 2.8" TFT Touchscreen

## Bitmaps

Info: 

We have an example sketch in the library showing how to display full color bitmap images stored on an SD card. You'll need an SD or [microSD breakout board such as this one](http://www.adafruit.com/index.php?main_page=product_info&cPath=42&products_id=254).  
  
Modern versions of the Arduino software (0023, or 1.0 or later) **already&nbsp;include an SD card library**. If you're holding out with an old version of the Arduino IDE, you can&nbsp;[download our library here](https://github.com/adafruit/SD). Click the **Download ZIP** &nbsp;button, uncompress the archive and rename the resulting folder to “ **SD** ”. Move this folder into your Arduino libraries folder (usually [home]/Documents/Arduino/Libraries) and restart the IDE.  
  
Wire up the TFT as we have before (see previous page) and then wire up the microSD card breakout.  
  
On an Uno/Duemilanove you will want to use the following connections: Connect the SD card with **DI** going to pin **11** , **DO** going to pin **12** and **SCK** going to pin **13** (this is standard on all our shields) Then pin **10** goes to **CS**. For MEGA, check the SPI connections go to the Mega's SPI pins (not 10-13)  
  
Copy the **woof.bmp** and **miniwoof.bmp** files to a microSD card and insert it into the breakout. Run the **tftbmp** example sketch in the TFTLCD library, you should see the images show up. If not, check the serial monitor for hints as to why it may not be working.

![](https://cdn-learn.adafruit.com/assets/assets/000/003/051/medium800/lcds___displays_28tfttouchbreakoutwoof_LRG.jpg?1396790646)

# 2.8" TFT Touchscreen

## Downloads

Info: 

- [Touch screen library](https://github.com/adafruit/Touch-Screen-Library)
- [TFT LCD library](https://github.com/adafruit/TFTLCD-Library)
- [GFX library](https://github.com/adafruit/Adafruit-GFX-Library)
- [SD card library](https://github.com/adafruit/SD) ( **not needed** if running [up-to-date Arduino IDE](http://arduino.cc/en/Main/Software)!)
- [Breakout board schematic](http://learn.adafruit.com/system/assets/assets/000/010/148/original/tfttouchbreakoutsch.png)  

# 2.8" TFT Touchscreen

## Support Forums


## Featured Products

### Adafruit METRO 328 Fully Assembled - Arduino IDE compatible

[Adafruit METRO 328 Fully Assembled - Arduino IDE compatible](https://www.adafruit.com/product/50)
We sure love the ATmega328 here at Adafruit, and we use them&nbsp;_a lot_&nbsp;for our own projects. The processor has plenty of GPIO, Analog inputs, hardware UART SPI and I2C, timers and PWM galore - just enough for most simple projects. When we need to go small, we use a <a...></a...>

Out of Stock
[Buy Now](https://www.adafruit.com/product/50)
[Related Guides to the Product](https://learn.adafruit.com/products/50/guides)
### Breadboarding wire bundle

[Breadboarding wire bundle](https://www.adafruit.com/product/153)
75 flexible stranded core wires with stiff ends molded on in red, orange, yellow, green, blue, brown, black and white. These are a major improvement over the "box of bent wires" that are sometimes sold with breadboards, and faster than stripping your own solid core wires. Makes...

In Stock
[Buy Now](https://www.adafruit.com/product/153)
[Related Guides to the Product](https://learn.adafruit.com/products/153/guides)
### Half Sized Premium Breadboard - 400 Tie Points

[Half Sized Premium Breadboard - 400 Tie Points](https://www.adafruit.com/product/64)
This is a cute, half-size breadboard with&nbsp;400 tie points, good for small projects. It's 3.25" x 2.2" / 8.3cm&nbsp;x 5.5cm&nbsp;with a standard double-strip in the middle and two power rails on both sides.&nbsp;You can pull the power rails off easily to make the breadboard as...

In Stock
[Buy Now](https://www.adafruit.com/product/64)
[Related Guides to the Product](https://learn.adafruit.com/products/64/guides)
### MicroSD card breakout board+

[MicroSD card breakout board+](https://www.adafruit.com/product/254)
Not just a simple breakout board, this microSD adapter goes the extra mile - designed for ease of use.

- Onboard 5v-\>3v regulator provides 150mA for power-hungry cards
- 3v level shifting means you can use this with ease on either 3v or 5v systems
- Uses a proper level...

Out of Stock
[Buy Now](https://www.adafruit.com/product/254)
[Related Guides to the Product](https://learn.adafruit.com/products/254/guides)

## Related Guides

- [Memories of an Arduino](https://learn.adafruit.com/memories-of-an-arduino.md)
- [WiFi Weather Station](https://learn.adafruit.com/wifi-weather-station-arduino-cc3000.md)
- [Adafruit 1.27" and 1.5" Color OLED Breakout Board](https://learn.adafruit.com/adafruit-1-5-color-oled-breakout-board.md)
- [Wireless Gardening with Arduino + CC3000 WiFi Modules](https://learn.adafruit.com/wireless-gardening-arduino-cc3000-wifi-modules.md)
- [Ladyada's Learn Arduino - Lesson #0](https://learn.adafruit.com/ladyadas-learn-arduino-lesson-number-0.md)
- [Introducing Adafruit Trellis ](https://learn.adafruit.com/adafruit-trellis-diy-open-source-led-keypad.md)
- [Skill Badge Requirements: Microcontrollers](https://learn.adafruit.com/skill-badge-requirements-microcontrollers.md)
- [Smart Cocktail Shaker](https://learn.adafruit.com/smart-cocktail-shaker.md)
- [Arduino Lesson 6. Digital Inputs](https://learn.adafruit.com/adafruit-arduino-lesson-6-digital-inputs.md)
- [Arduino Lesson 14. Servo Motors](https://learn.adafruit.com/adafruit-arduino-lesson-14-servo-motors.md)
- [WiFi Controlled LED Christmahanukwanzaa Tree](https://learn.adafruit.com/wifi-controlled-led-christmahanukwanzaa-tree.md)
- [FTDI Friend](https://learn.adafruit.com/ftdi-friend.md)
- [Digital Circuits 6: An EPROM Emulator](https://learn.adafruit.com/digital-circuits-6-eprom-emulator.md)
- [3D Printed Animatronic Robot Head](https://learn.adafruit.com/3d-printed-animatronic-robot-head.md)
- [Adafruit Analog Accelerometer Breakouts](https://learn.adafruit.com/adafruit-analog-accelerometer-breakouts.md)
