I am also looking for a library for the ili9341 lcd.
I have tried adafruits and one from seeedstudio and could not get either to display anything.
Wired as per the instructions for each library.. (the two we're slightly different)
i'm testing this lcd bought from ebay also with my uno. struggled for a day and after reading the specification, i believe most of us make a very simple mistake. the voltage. u need 3.3v to talk to this unit. my uno is 5v, so i use few resistors and make a voltage divider and guess what, the display is working.
tried seeedTFT, fast, small but limited function. UTFT is great, but the program is too heavy for uno.
You follow this connection schema? I tried using a HCF4050 but for me not working =(
Pinout (Arduino : TFT)
D4 : RESET
D5 : CS
D6 : D/C
D7 : LED
D11 : MOSI
D12 : MISO
D13 : SCK
nid69ita:
You follow this connection schema? I tried using a HCF4050 but for me not working =(
Pinout (Arduino : TFT)
D4 : RESET
D5 : CS
D6 : D/C
D7 : LED
D11 : MOSI
D12 : MISO
D13 : SCK
Not the same display, but the same general idea. Here is how I have it wired:
Click to enlarge.
The MISO pin should go directly back to your Arduino, without going through the 4050.
I have a problem. I used seedstudio library and for one time screen is okay (text demo).
But after, moving TFT and/or breadboard with cd4050 not work.
Sometimes I reset Arduino and only a part of image visible and in a microsecond all white.
Can be a problem about my breadboard, or header of TFT (it arrived already soldered) ?
I purchased a 1.8" (got working) and this 2.2" tft display from eBay. I haven't been able to get this 2.2" display to work either. Although I tried it but no luck, that if 3V is required, can it be done with mega?
matchy:
I purchased a 1.8" (got working) and this 2.2" tft display from eBay. I haven't been able to get this 2.2" display to work either. Although I tried it but no luck, that if 3V is required, can it be done with mega?
?? Arduino Mega? Also on Arduino Mega signals on pins are at 5V.
Arduino Uno and Mega have a pin at 3.3V but all other pins are at 5V.
Hi, now my TFT 2.2" work.
I made a little stripboard with CD4050 and with fixed connection now work !
Thanks to all and specially to @TheCoolest; MISO connected directly to Arduino
Another question about this TFT.
Also it have a SD. Somebody know how it work? I need to solder a 4 pin header?
I think GND and 3V3 is used from display header.
Regarding the SD, it also requires 3.3v to work. The MOSI, MISO and SCK pins are shared with the LCD, you'll only need one extra pin for CS to go to the SD card slot.
Friends, I have a TFT with 2.2SP ili9341 (even that has nid69ita) working on nano and I can make it work with the sketch below (using 22k resistors instead of using cd4050). I tried to use the librarie suggested by chisco and pinout suggested by nid69ita and then the TheCoolest and none of them worked. Can anyone help me?
/*==========================================================================
The LCD connection is the same as Nokia LCD5110 and is a?? Bit Pant Demo??
Just for ElecFreaks TFT01-2.2SP, which use SPI serial port and 240x320 pixel.
The driver is ILI9341.
by Elecfreaks
==========================================================================*/
#include "pins_arduino.h"
//USAR O PINO 8 DO TFT PARA DETERMINAR O BRILHO DO DISPLAY
#define LCD_WR 9 //SCL - PINO 7 DO TFT
#define LCD_RS 10 //SDA - PINO 6 DO TFT
#define LCD_DC 11 //A0 - PINO 5 DO TFT
#define LCD_REST 12 //RESET - PINO 4 DO TFT
#define LCD_CS 13 //CSE - PINO 3 DO TFT
volatile uint8_t *P_SCK, *P_MOSI, *P_DC, *P_RST, *P_CS;
volatile uint8_t B_SCK, B_MOSI, B_DC, B_RST, B_CS;
void LCD_Writ_Bus(char data)
{
*P_CS &= ~B_CS;
for (unsigned char c=0; c<8; c++)
{
if (data & 0x80)
*P_MOSI |= B_MOSI;
else
*P_MOSI &= ~B_MOSI;
data = data<<1;
*P_SCK &= ~B_SCK;
asm ("nop");
*P_SCK |= B_SCK;
}
*P_CS |= B_CS;
}
void LCD_Write_COM(char VL)
{
digitalWrite(LCD_DC,LOW);
LCD_Writ_Bus(VL);
}
void LCD_Write_DATA(char VL)
{
digitalWrite(LCD_DC,HIGH);
LCD_Writ_Bus(VL);
}
void Address_set(unsigned int x1,unsigned int y1,unsigned int x2,unsigned int y2)
{
LCD_Write_COM(0x2a);
LCD_Write_DATA(x1>>8);
LCD_Write_DATA(x1);
LCD_Write_DATA(x2>>8);
LCD_Write_DATA(x2);
LCD_Write_COM(0x2b);
LCD_Write_DATA(y1>>8);
LCD_Write_DATA(y1);
LCD_Write_DATA(y2>>8);
LCD_Write_DATA(y2);
LCD_Write_COM(0x2C);
}
void LCD_Init(void)
{
P_SCK = portOutputRegister(digitalPinToPort(LCD_WR));
B_SCK = digitalPinToBitMask(LCD_WR);
P_MOSI = portOutputRegister(digitalPinToPort(LCD_RS));
B_MOSI = digitalPinToBitMask(LCD_RS);
P_DC = portOutputRegister(digitalPinToPort(LCD_DC));
B_DC = digitalPinToBitMask(LCD_DC);
P_RST = portOutputRegister(digitalPinToPort(LCD_REST));
B_RST = digitalPinToBitMask(LCD_REST);
P_CS = portOutputRegister(digitalPinToPort(LCD_CS));
B_CS = digitalPinToBitMask(LCD_CS);
*P_RST &= ~B_RST;
delay(10);
*P_RST |= B_RST;
LCD_Write_COM(0xCB);
LCD_Write_DATA(0x39);
LCD_Write_DATA(0x2C);
LCD_Write_DATA(0x00);
LCD_Write_DATA(0x34);
LCD_Write_DATA(0x02);
LCD_Write_COM(0xCF);
LCD_Write_DATA(0x00);
LCD_Write_DATA(0XC1);
LCD_Write_DATA(0X30);
LCD_Write_COM(0xE8);
LCD_Write_DATA(0x85);
LCD_Write_DATA(0x00);
LCD_Write_DATA(0x78);
LCD_Write_COM(0xEA);
LCD_Write_DATA(0x00);
LCD_Write_DATA(0x00);
LCD_Write_COM(0xED);
LCD_Write_DATA(0x64);
LCD_Write_DATA(0x03);
LCD_Write_DATA(0X12);
LCD_Write_DATA(0X81);
LCD_Write_COM(0xF7);
LCD_Write_DATA(0x20);
LCD_Write_COM(0xC0); //Power control
LCD_Write_DATA(0x23); //VRH[5:0]
LCD_Write_COM(0xC1); //Power control
LCD_Write_DATA(0x10); //SAP[2:0];BT[3:0]
LCD_Write_COM(0xC5); //VCM control
LCD_Write_DATA(0x3e); //Contrast
LCD_Write_DATA(0x28);
LCD_Write_COM(0xC7); //VCM control2
LCD_Write_DATA(0x86); //--
LCD_Write_COM(0x36); // Memory Access Control
LCD_Write_DATA(0x48); //C8 //48 68???//28 E8 ???
LCD_Write_COM(0x3A);
LCD_Write_DATA(0x55);
LCD_Write_COM(0xB1);
LCD_Write_DATA(0x00);
LCD_Write_DATA(0x18);
LCD_Write_COM(0xB6); // Display Function Control
LCD_Write_DATA(0x08);
LCD_Write_DATA(0x82);
LCD_Write_DATA(0x27);
/*
LCD_Write_COM(0xF2); // 3Gamma Function Disable
LCD_Write_DATA(0x00);
LCD_Write_COM(0x26); //Gamma curve selected
LCD_Write_DATA(0x01);
LCD_Write_COM(0xE0); //Set Gamma
LCD_Write_DATA(0x0F);
LCD_Write_DATA(0x31);
LCD_Write_DATA(0x2B);
LCD_Write_DATA(0x0C);
LCD_Write_DATA(0x0E);
LCD_Write_DATA(0x08);
LCD_Write_DATA(0x4E);
LCD_Write_DATA(0xF1);
LCD_Write_DATA(0x37);
LCD_Write_DATA(0x07);
LCD_Write_DATA(0x10);
LCD_Write_DATA(0x03);
LCD_Write_DATA(0x0E);
LCD_Write_DATA(0x09);
LCD_Write_DATA(0x00);
LCD_Write_COM(0XE1); //Set Gamma
LCD_Write_DATA(0x00);
LCD_Write_DATA(0x0E);
LCD_Write_DATA(0x14);
LCD_Write_DATA(0x03);
LCD_Write_DATA(0x11);
LCD_Write_DATA(0x07);
LCD_Write_DATA(0x31);
LCD_Write_DATA(0xC1);
LCD_Write_DATA(0x48);
LCD_Write_DATA(0x08);
LCD_Write_DATA(0x0F);
LCD_Write_DATA(0x0C);
LCD_Write_DATA(0x31);
LCD_Write_DATA(0x36);
LCD_Write_DATA(0x0F);
*/
LCD_Write_COM(0x11); //Exit Sleep
delay(120);
LCD_Write_COM(0x29); //Display on
LCD_Write_COM(0x2c);
}
void Pant(char VL)
{
int i,j;
Address_set(0,0,240,320);
for(i=0;i<320;i++)
{
for (j=0;j<480;j++)
{
LCD_Write_DATA(VL);
}
}
}
void setup()
{
unsigned char p;
for(p=8;p<14;p++)
pinMode(p,OUTPUT);
LCD_Init();
}
void loop()
{
Pant(0xFF);
Pant(0xF0);
Pant(0xE0);
Pant(0x05);
Pant(0x1F);
Pant(0x00);
}
Hi @daniel. You tried the library on Nano or other Arduino boards?
For me the code you posted is strange. I already see it before but in the comment part there are some information for me very strange.
SCL and SDA are the names of pin for I2C wiring and not for SPI. The pin for SPI are MOSI/MISO/SCK and SS o CS
Pins SCL,SDA,MISO,MOSI and SCK are fixed in every Arduino (not the same on Uno or Mega).
Other pins can be assigned every you want. But not this special pins.
I looked at the links you showed me and did exactly as you suggested, put a CD4050 and tested before the other sketch already worked with the resistors.
I put the sketch TFT_text (see below the code and TFT.h and TFTv2.h) and it worked, but the screen flickers(flashes quickly as if the arduino pin resetting) and the image is mirrored. So I tried to use the TFTv2 did not work.
Reviewed the TFT_text and found nothing related to blinks (see the video in - YouTube).
Another detail when I change cd4050 for resistors the screen does not work.
Any idea?
Thank you!
#include <TFT.h> // Arduino LCD library
#include <SPI.h>
// pin definition for the Uno
#define cs 10
#define dc 9
#define rst 8
// CS pin 3 of tft conected in arduino pin 10
// RST pin 4 of tft conected in arduino pin 8
// D/C pin 5 of tft conected in arduino pin 9
// MOSI pin 6 of tft conected in arduino pin 11
// SCLK pin 7 of tft conected in arduino pin 13
// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
//TFT TFTscreen = TFT(cs, rst, dc); //not work
//TFT TFTscreen = TFT(dc, cs, rst); //not work
//TFT TFTscreen = TFT(dc, rst, cs); //not work
//TFT TFTscreen = TFT(rst, cs, dc); //not work
//TFT TFTscreen = TFT(rst, dc, cs); //not work
// char array to print to the screen
char sensorPrintout[4];
void setup() {
// Put this line at the beginning of every sketch that uses the GLCD:
TFTscreen.begin();
// clear the screen with a black background
TFTscreen.background(0, 0, 0);
// write the static text to the screen
// set the font color to white
TFTscreen.stroke(255,255,255);
// set the font size
TFTscreen.setTextSize(2);
// write the text to the top left corner of the screen
TFTscreen.text("Sensor Value :\n ",0,0);
// ste the font size very large for the loop
TFTscreen.setTextSize(5);
}
void loop() {
// Read the value of the sensor on A0
String sensorVal = String(analogRead(A0));
// convert the reading to a char array
sensorVal.toCharArray(sensorPrintout, 4);
// set the font color
TFTscreen.stroke(255,255,255);
// print the sensor value
TFTscreen.text(sensorPrintout, 0, 20);
// wait for a moment
delay(250);
// erase the text you just wrote
TFTscreen.stroke(0,0,0);
TFTscreen.text(sensorPrintout, 0, 20);
}
@daniel, I tried also with my Arduino Nano V.3 (a clone) and it work.
My Arduino Nano is at 5V, so I used my little conversion board.
I attach the library I used (a file rar). The library you post is different from my. I tested on Nano using the example named text.ino
In this library pins are fixed (obviously for SCK/MISO/MOSI):
D4 : RESET
D5 : CS
D6 : D/C
D7 : LED
D11 : MOSI
D12 : MISO
D13 : SCK
In the TFT.h you attach, there is a note:
/// The Arduino LCD is a ST7735-based device. .....
class TFT : public Adafruit_ST7735 {
public:
TFT(uint8_t CS, uint8_t RS, uint8_t RST);
It is based and call also other library from Adafruits. But refer to ST7735 !?!?
The constructor is fixed: CS, RS (dc??), RST so this can work