Wiring up the 8-bit mode is kind of a pain, so we really only recommend doing it for UNO (which we show) and Mega (which we describe, and is pretty easy since its 8 pins in a row). Anything else, like a Leonardo or Micro, we strongly recommend going with SPI mode since we don't have an example for that. Any other kind of 'Arduino compatible' that isn't an Uno, try SPI first. The 8-bit mode is hand-tweaked in the Adafruit_TFTLCD pin_magic.h file. Its really only for advanced users who are totally cool with figuring out bitmasks for various ports & pins.
Really, we'll show how to do the UNO but anything else? go with SPI!
In these images we show using our 2.8" TFT but its the exact same pinout, just a tad smaller!
Begin by wiring up the 3-5VDC and GND pins.
Connect the 3-5V pin to 5V and GND to GND on your Arduino. I'm using the breadboard rails but you can also just wire directly.
Power it up and you should see the white backlight come on
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.
However, they are not in that order! D0 and D1 go to digital #8 and #9, then D2-D7 connect to #2 thru #7. This is because Arduino pins #0 and #1 are used for serial data so we can't use them
Begin by connecting D0 and D1 to digital #8 and 9 respectively as seen above. If you're using a Mega, connect the TFT Data Pins D0-D1 to Mega pins #22-23, in that order. Those Mega pins are on the 'double' header.
Now you can connect the remaining 6 pins over. Connect D2-D7 on the TFT pins to digital 2 thru 7 in that order. If you're using a Mega, connect the TFT Data Pins D2-D7 to Mega pins #24-29, in that order. Those Mega pins are on the 'double' header.
In addition to the 8 data lines, you'll also need 4 or 5 control lines. These can later be reassigned to any digital pins, they're just what we have in the tutorial by default.
- 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
You can connect the seventh pin RST (Reset) to the Arduino Reset line if you'd like. This will reset the panel when the Arduino is Reset. You can also use a digital pin for the LCD reset if you want to manually reset. There's auto-reset circuitry on the board so you probably don't need to use this pin at all and leave it disconnected
The RD pin is used to read the chip ID off the TFT. Later, once you get it all working, you can remove this pin and the ID test, although we suggest keeping it since its useful for debugging your wiring.
OK! Now we can run some code
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: first is the Adafruit_TFTLCD library (this contains the low-level code specific to this device).
Download the ZIP file, uncompress and rename the folder to Adafruit_TFTLCD (contains Adafruit_TFTLCD.cpp and .h). Then place it inside your Arduino libraries folder and restart the Arduino IDE. If this is all unfamiliar, we have a tutorial introducing Arduino library concepts and installation.
You can install the GFX library through the Arduino library manager.
Open up the Arduino library manager:
Search for the Adafruit GFX library and install it
We also have a great tutorial on Arduino library installation at:
In the Adafruit_TFTLCD Library folder, you may need to edit Adafruit_TFTLCD.h. On about line 12, you will see
Make sure this line is commented out with a // in front (it should but if you're having issues, its worth checking.
Next up, we originally designed this library for 320x240 TFTs. Since this is a 480x320, we have to adjust the size the library is expecting. Open up Adafruit_TFTLCD.cpp and find these lines:
Comment out the 240 and 320 lines, and uncomment the 320 and 480 lines:
Save it, now you can upload the demo!
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.
(The images below shows SPI wiring but the graphical output should be similar!)
If you're having difficulties, check the serial console.The first thing the sketch does is read the driver code from the TFT. It should be 0x8357 (for the HX8357D controller inside)
If you Unknown Driver Chip then it's probably something with your wiring, double check and try again!