ADVERTISEMENT
ili9341 tft display with arduino promini 3.3volt/8mhz |
Important Notes on connecting the ili9341 tft display to Arduino
1) This display uses 3.3 volts! So when i used this display with an arduino uno at 5volt, i got a white screen , with nothing else!! So i ended up getting an arduino pro mini which works on 3.3 volt. So you need a level shifter , if you intend to use it at 5volt. A simple solution for testing is to use two 1.5 volt batteries (3volt) and connect the ground to ground of an arduino uno and positive to vcc (5v)of a uno. This worked in my case for testing the display. I recommend a level shifter for stable results.
2) The led pin needs a resistor to control the current ( i used a 47 ohm resistor). Display works without this but you may risk a damage in the long run.
3) Wiring is simple, follow the one given in github page
+----------------+ | (Arduino: TFT) | +----------------+ | D4 : RESET | | D5 : CS | | D6 : D/C | | D7 : LED | | D11 : MOSI | | D12 : MISO | | D13 : SCK | +----------------+
4) For testing , there is an example folder with some sample sketches and just load one of them. See figure below
4) For example drawCircles will output the first figure in this blog post (red and blue circles)
Advanced features like landscape mode, additional fonts and rotating the display
The library listed above will provide some basic functionality. But the sketch memory size is relatively small in terms of flash usage (max 30-32k on atmega328). But an other library called ucglibrary offers a lot more features and fonts. This can be downloaded here (ucglib). Use the same steps for library installation. If you have the same wiring as above, open an example sketch under the ucglib (Hellow world) and then
1) Add Ucglib_ILI9341_18x240x320_HWSPI ucg( 6, 5, 4);
and in setup() of the sketch , add the following line to turn the backlight on
pinMode(7, OUTPUT);
digitalWrite(7, HIGH);
To set the display in landscape mode, use
ucg.setRotate90()
preferably in the setup of the code. See example below
#include <SPI.h>
#include "Ucglib.h"
/*
Hardware SPI Pins:
Arduino Uno sclk=13, data=11
Arduino Due sclk=76, data=75
Arduino Mega sclk=52, data=51
>>> Please uncomment (and update) one of the following constructors. <<<
*/
Ucglib_ILI9341_18x240x320_HWSPI ucg( 6, 5, 4);
void setup(void)
{
pinMode(7, OUTPUT);
digitalWrite(7, HIGH);
delay(1000);
ucg.begin(UCG_FONT_MODE_TRANSPARENT);
ucg.clearScreen();
ucg.setRotate90();
}
void loop(void)
{
ucg.setFont(ucg_font_ncenR14r);
ucg.setColor(255, 255, 255);
ucg.setColor(255, 0, 0);
ucg.setColor(1, 255, 0,0);
ucg.setPrintPos(0,25);
ucg.print("Hello World!");
ucg.setPrintPos(1,50);
ucg.print("Hello World!");
delay(500);
}
end
you refer to pin 7 for LED in wiring and text, but output to pin 10 in code?
ReplyDeleteYes, it should be 7, otherwise display may stay dark. Thanks for the correction
DeleteI'm using an Arduino Nano which has a 3.3v output.
ReplyDeleteWhen I run any of the samples the display comes on but only a white screen. Any suggestions?
It should be black. Double check the connections ( mosi,miso, sck, cs). Check the voltages with a multmeteter.
DeleteDriving myself nuts here. I have verified the voltages and connections.
DeleteI even tried an uno/display combo that had worked in the past and all I get is a white screen no matter what example I use. Very frustrating.
You should power the display from a separate power supply. I encounter the same behavior when power from Nano. An external 3.3V for the display should do the job.
Delete