Before you start, we'll need to tell the display to put us in SPI mode so it will know which pins to listen to. To do that, we have to connect the IM2 pin to 3.3V. The easiest way to do that is to solder closed the IM2 jumper on the back of the PCB. Turn over the PCB and find the solder jumper:
With your soldering iron, melt solder to close the jumper indicated IM2
If you really don't want to solder, you can also wire the breakout pin to the 3vo pin, just make sure you don't tie it to 5V by accident! For that reason, we suggest going with the solder-jumper route.
Wiring up the display in SPI mode is much easier than 8-bit mode since there's way fewer wires. Start by connecting the power pins
- 3-5V Vin connects to the Arduino 5V pin
- GND connects to Arduino ground
- CLK connects to SPI clock. On Arduino Uno/Duemilanove/328-based, thats Digital 13. On Mega's, its Digital 52 and on Leonardo/Due its ICSP-3 (See SPI Connections for more details)
- MISO connects to SPI MISO. On Arduino Uno/Duemilanove/328-based, thats Digital 12. On Mega's, its Digital 50 and on Leonardo/Due its ICSP-1 (See SPI Connections for more details)
- MOSI connects to SPI MOSI. On Arduino Uno/Duemilanove/328-based, thats Digital 11. On Mega's, its Digital 51 and on Leonardo/Due its ICSP-4 (See SPI Connections for more details)
- CS connects to our SPI Chip Select pin. We'll be using Digital 10 but you can later change this to any pin
- D/C connects to our SPI data/command select pin. We'll be using Digital 9 but you can later change this pin too.
That's it! You do not need to connect the RST or other pins for now.
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.
Three libraries need to be installed using the Arduino Library Manager…this is the preferred and modern way. From the Arduino “Sketch” menu, select “Include Library” then “Manage Libraries…”
Type “gfx” in the search field to quickly find the first library — Adafruit_GFX:
Repeat the search and install steps, looking for the Adafruit_ZeroDMA and Adafruit_HX8357 libraries.
After restarting the Arduino software, you should see a new example folder called Adafruit_HX8357 and inside, an example called graphicstest.
Upload the graphicstest 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.
If you're having difficulties, check the serial console.The first thing the sketch does is read the driver configuration from the TFT, you should see the same numbers as below
If you did not connect up the MISO line to the TFT, you wont see the read configuation bytes so please make sure you connect up the MISO line for easy debugging! Once its all working, you can remove the MISO line