2.4 TFT LCD helpp

I downloaded and tried almost every examples but i still get a freakin white screen. Im feelin like I just wasted ny money helpp huhu im desperate haha. Also after that is it possible to display the voltage reading of a battery in our 2.4 tft lcd? Thanks!

If you want help, you should post a link to your actual display. e.g. the Ebay sale.

Yes, of course you can read a voltage that is within the operating range of your Uno's ADC reference. This means using a pair of resistors as a potential divider.

If you have a "high power" Solar array, you probably run your Arduino at 5V and this is accurately held by the Arduino's voltage regulator. If so, you can use 5V as reference.

Low Power systems would run at a low voltage and use the 1.1V BandGap reference.

David.

david_prentice:
If you want help, you should post a link to your actual display. e.g. the Ebay sale.

Yes, of course you can read a voltage that is within the operating range of your Uno’s ADC reference.
This means using a pair of resistors as a potential divider.

If you have a “high power” Solar array, you probably run your Arduino at 5V and this is accurately held by the Arduino’s voltage regulator. If so, you can use 5V as reference.

Low Power systems would run at a low voltage and use the 1.1V BandGap reference.

David.

Good evening david! I bought mine at a shop here in the philippines, they gave me drivers but it didn’t work so i tried other libraries but it doesn’t work either. I tried this sample code.

#include <Adafruit_GFX.h> // Core graphics library
#include <SWTFT.h> // Hardware-specific library
#include <TouchScreen.h>

#define YP A1 // must be an analog pin, use “An” notation!
#define XM A2 // must be an analog pin, use “An” notation!
#define YM 7 // can be a digital pin
#define XP 6 // can be a digital pin

#define TS_MINX 150
#define TS_MINY 120
#define TS_MAXX 920
#define TS_MAXY 940

// For better pressure precision, we need to know the resistance
// between X+ and X- Use any multimeter to read it
// For the one we’re using, its 300 ohms across the X plate
TouchScreen ts = TouchScreen(XP, YP, XM, YM, 300);

// Assign human-readable names to some common 16-bit color values:
#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define CYAN 0x07FF
#define MAGENTA 0xF81F
#define YELLOW 0xFFE0
#define WHITE 0xFFFF

SWTFT tft;

#define BOXSIZE 40
#define PENRADIUS 3
int oldcolor, currentcolor;

void setup(void) {
Serial.begin(9600);
Serial.println(F(“Paint!”));

tft.reset();

uint16_t identifier = tft.readID();

Serial.print(F("LCD driver chip: "));
Serial.println(identifier, HEX);

tft.begin(identifier);

tft.fillScreen(BLACK);

tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);
tft.fillRect(BOXSIZE2, 0, BOXSIZE, BOXSIZE, GREEN);
tft.fillRect(BOXSIZE
3, 0, BOXSIZE, BOXSIZE, CYAN);
tft.fillRect(BOXSIZE4, 0, BOXSIZE, BOXSIZE, BLUE);
tft.fillRect(BOXSIZE
5, 0, BOXSIZE, BOXSIZE, MAGENTA);
// tft.fillRect(BOXSIZE*6, 0, BOXSIZE, BOXSIZE, WHITE);

tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
currentcolor = RED;

pinMode(13, OUTPUT);
}

#define MINPRESSURE 10
#define MAXPRESSURE 1000

void loop()
{
digitalWrite(13, HIGH);
// Recently Point was renamed TSPoint in the TouchScreen library
// If you are using an older version of the library, use the
// commented definition instead.
// Point p = ts.getPoint();
TSPoint p = ts.getPoint();
digitalWrite(13, LOW);

// if sharing pins, you’ll need to fix the directions of the touchscreen pins
//pinMode(XP, OUTPUT);
pinMode(XM, OUTPUT);
pinMode(YP, OUTPUT);
//pinMode(YM, OUTPUT);

// we have some minimum pressure we consider ‘valid’
// pressure of 0 means no pressing!

if (p.z > MINPRESSURE && p.z < MAXPRESSURE) {
/*
Serial.print("X = “); Serial.print(p.x);
Serial.print(”\tY = “); Serial.print(p.y);
Serial.print(”\tPressure = "); Serial.println(p.z);
*/

if (p.y < (TS_MINY-5)) {
Serial.println(“erase”);
// press the bottom of the screen to erase
tft.fillRect(0, BOXSIZE, tft.width(), tft.height()-BOXSIZE, BLACK);
}
// scale from 0->1023 to tft.width
p.x = tft.width()-(map(p.x, TS_MINX, TS_MAXX, tft.width(), 0));
p.y = tft.height()-(map(p.y, TS_MINY, TS_MAXY, tft.height(), 0));
/*
Serial.print("("); Serial.print(p.x);
Serial.print(", “); Serial.print(p.y);
Serial.println(”)");
*/
if (p.y < BOXSIZE) {
oldcolor = currentcolor;

if (p.x < BOXSIZE) {
currentcolor = RED;
tft.drawRect(0, 0, BOXSIZE, BOXSIZE, WHITE);
} else if (p.x < BOXSIZE2) {
currentcolor = YELLOW;
tft.drawRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, WHITE);
} else if (p.x < BOXSIZE
3) {
currentcolor = GREEN;
tft.drawRect(BOXSIZE2, 0, BOXSIZE, BOXSIZE, WHITE);
} else if (p.x < BOXSIZE
4) {
currentcolor = CYAN;
tft.drawRect(BOXSIZE3, 0, BOXSIZE, BOXSIZE, WHITE);
} else if (p.x < BOXSIZE
5) {
currentcolor = BLUE;
tft.drawRect(BOXSIZE4, 0, BOXSIZE, BOXSIZE, WHITE);
} else if (p.x < BOXSIZE
6) {
currentcolor = MAGENTA;
tft.drawRect(BOXSIZE*5, 0, BOXSIZE, BOXSIZE, WHITE);
}

if (oldcolor != currentcolor) {
if (oldcolor == RED) tft.fillRect(0, 0, BOXSIZE, BOXSIZE, RED);
if (oldcolor == YELLOW) tft.fillRect(BOXSIZE, 0, BOXSIZE, BOXSIZE, YELLOW);
if (oldcolor == GREEN) tft.fillRect(BOXSIZE2, 0, BOXSIZE, BOXSIZE, GREEN);
if (oldcolor == CYAN) tft.fillRect(BOXSIZE
3, 0, BOXSIZE, BOXSIZE, CYAN);
if (oldcolor == BLUE) tft.fillRect(BOXSIZE4, 0, BOXSIZE, BOXSIZE, BLUE);
if (oldcolor == MAGENTA) tft.fillRect(BOXSIZE
5, 0, BOXSIZE, BOXSIZE, MAGENTA);
}
}
if (((p.y-PENRADIUS) > BOXSIZE) && ((p.y+PENRADIUS) < tft.height())) {
tft.fillCircle(p.x, p.y, PENRADIUS, currentcolor);
}
}
}

Here’s also photos of my 2.4 tft. Hope you can help me. Appreciate it! Thank you :slight_smile:

Thanks for the photo of the pcb.

Your Shield looks like a regular Red 2.4" Mcufriend Uno Display Shield.
i.e. with two 74HC245 buffers and a microSD holder

I have never seen your pcb in real life.
Most of them have a AMS1117 regulator for the Backlight LED and do not have a footprint for a Flash chip.

I suggest that you install the MCUFRIEND_kbv library from the IDE Library Manager.

Run the LCD_ID_readreg.ino from the Examples. Copy-Paste the output from the Serial Terminal to your message.

David.

This is the actual look of the TFT LCD…

Read Registers on MCUFRIEND UNO shield controllers either read as single 16-bit e.g. the ID is at readReg(0) or as a sequence of 8-bit values in special locations (first is dummy)

reg(0x0000) 05 01 ID: ILI9320, ILI9325, ILI9335, ... reg(0x0004) 00 00 00 00 Manufacturer ID reg(0x0009) 08 08 08 08 08 Status Register reg(0x000A) 0F 0B Get Powsr Mode reg(0x000C) 08 08 Get Pixel Format reg(0x0061) 60 60 RDID1 HX8347-G reg(0x0062) 67 63 RDID2 HX8347-G reg(0x0063) 62 62 RDID3 HX8347-G reg(0x0064) 60 60 RDID1 HX8347-A reg(0x0065) 60 60 RDID2 HX8347-A reg(0x0066) 62 62 RDID3 HX8347-A reg(0x0067) 62 62 RDID Himax HX8347-A reg(0x0070) 75 71 Panel Himax HX8347-A reg(0x00A1) A0 A0 A0 A0 A0 RD_DDB SSD1963 reg(0x00B0) B5 B1 RGB Interface Signal Control reg(0x00B4) B0 B0 Inversion Control reg(0x00B6) B2 B2 B2 B2 B2 Display Control reg(0x00B7) B2 B2 Entry Mode Set reg(0x00BF) BA BA BA BA BA BA ILI9481, HX8357-B reg(0x00C0) C5 C1 C5 C1 C5 C1 C5 C1 C5 Panel Control reg(0x00C8) C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 C8 GAMMA reg(0x00CC) C8 C8 Panel Control reg(0x00D0) D5 D1 D5 Power Control reg(0x00D2) D2 D2 D2 D2 D2 NVM Read reg(0x00D3) D2 D2 D2 D2 ILI9341, ILI9488 reg(0x00DA) DA DA RDID1 reg(0x00DB) DA DA RDID2 reg(0x00DC) D8 D8 RDID3 reg(0x00E0) E5 E1 E5 E1 E5 E1 E5 E1 E5 E1 E5 E1 E5 E1 E5 E1 GAMMA-P reg(0x00E1) E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 E0 GAMMA-N reg(0x00EF) EA EA EA EA EA EA ILI9327 reg(0x00F2) F7 F3 F7 F3 F7 F3 F7 F3 F7 F3 F7 F3 Adjust Control 2 reg(0x00F6) F2 F2 F2 F2 Interface Control

Here's the result of the serial monitor...

It looks as if you have a 16-bit non-MIPI controller with ID=0x0501. e.g. like an ILI9320

I have no idea what model or make this is.

I can only suggest that you edit the setup() function in the graphictest_kbv.ino sketch from the examples:

    ...
    uint16_t ID = tft.readID(); //
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    if (ID == 0xD3D3) ID = 0x9481; // write-only shield
    ID = 0x9320;             // try with 0x9320, 0x9325, 0x7783, 0x0154, ...
    tft.begin(ID);
}

Try each of the ID values. Report back if or how any of them work. I am not very hopeful. 0x0501 is an unlikely ID value.

You can always ask the shop if they know which controller. Or they could ask their Supplier. If I know the part number and can find a datasheet, I will make the library work with it.

David.

david_prentice: It looks as if you have a 16-bit non-MIPI controller with ID=0x0501. e.g. like an ILI9320

I have no idea what model or make this is.

I can only suggest that you edit the setup() function in the graphictest_kbv.ino sketch from the examples:

    ...
    uint16_t ID = tft.readID(); //
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    if (ID == 0xD3D3) ID = 0x9481; // write-only shield
    ID = 0x9320;             // try with 0x9320, 0x9325, 0x7783, 0x0154, ...
    tft.begin(ID);
}

Try each of the ID values. Report back if or how any of them work. I am not very hopeful. 0x0501 is an unlikely ID value.

You can always ask the shop if they know which controller. Or they could ask their Supplier. If I know the part number and can find a datasheet, I will make the library work with it.

David.

awwww... already ask them but they dont know it either. :( .. I'm just really new here,studying this tft for our thesis haha.. I can't move forward.... Thank you for your help man! Appreciate it :)

Well, you can ask them again.

You can give them my name if you want. It is good for their shop sales to have a library for their customers. It is good for their Wholesale Supplier to have a library for their Retail customers.

David.

david_prentice: It looks as if you have a 16-bit non-MIPI controller with ID=0x0501. e.g. like an ILI9320

I have no idea what model or make this is.

I can only suggest that you edit the setup() function in the graphictest_kbv.ino sketch from the examples:

    ...
    uint16_t ID = tft.readID(); //
    Serial.print("ID = 0x");
    Serial.println(ID, HEX);
    if (ID == 0xD3D3) ID = 0x9481; // write-only shield
    ID = 0x9320;             // try with 0x9320, 0x9325, 0x7783, 0x0154, ...
    tft.begin(ID);
}

Okay, one last question davidd.. do you have any idea what do I need to display the the voltage? and where to connect the arduino pins... by the way we also need to display the ampere rating of our battery and the internal resistance.. we still don't have ideas haha. thank you for your help david! highly appreciated :)

I answered that in #1.

If you are doing a thesis, you can work out the resistors for a potential divider.

You can Google how to read your Arduino supply voltage with the ADC. e.g. to check that you have got 5V via the regulator from your Solar Array.

If you are not sure of something, post a schematic. A pencil drawing is fine.

David.

david_prentice:
I answered that in #1.

If you are doing a thesis, you can work out the resistors for a potential divider.

You can Google how to read your Arduino supply voltage with the ADC. e.g. to check that you have got 5V via the regulator from your Solar Array.

If you are not sure of something, post a schematic. A pencil drawing is fine.

David.

Hi david is my connection correct? is this gonna work? btw our 2.4 tft lcd is now working :slight_smile: thank you for your help. Now im more concern with the program :smiley:

Your schematic does NOT match your Red 2.4" Mcufriend Shield. A5 is the only spare Analog pin.

The 10k, 15k divider is not correct. The 12.7V will produce (15 / (10 + 15)) * 12.7 = 7.62V 7.62V is too high for the ADC to read correctly.

You need to use different resistor values.

I am pleased that your TFT is working now. You should always plug the Shield into the Uno. What ID is reported by the graphictest_kbv.ino sketch?

You can snip off the A5 pin from the Shield. This will mean that you can access the A5 hole on the Uno header socket.

David.

david_prentice:
Your schematic does NOT match your Red 2.4" Mcufriend Shield. A5 is the only spare Analog pin.

The 10k, 15k divider is not correct. The 12.7V will produce (15 / (10 + 15)) * 12.7 = 7.62V
7.62V is too high for the ADC to read correctly.

You need to use different resistor values.

I am pleased that your TFT is working now. You should always plug the Shield into the Uno.
What ID is reported by the graphictest_kbv.ino sketch?

You can snip off the A5 pin from the Shield. This will mean that you can access the A5 hole on the Uno header socket.

David.

Hi david! I updated my schematic… I don’t have my 2.4 tft lcd here right now my classmate borrowed it. but here’s my new schematic. I used 3-30kohms resistor because that’s the only resistor available in the shop we went. Also in another picture, batteries of our generator is arranged just like whats on the schematic. Is it also possible to measure the internal resistance of the battery bank? 1 ,2 and 3? thank you David!

With your new schematic, the 12.7V will produce (10 / (10 + 90)) * 12.7 = 1.27V 1.27V is ok to read with your ADC.

But if you used a single 30k resistor: the 12.7V will produce (10 / (10 + 30)) * 12.7 = 3.175V 3.2V is ok to read with your ADC. You also have a safe margin when your batteries are overcharged.

I know nothing about linking multiple battery cells. I am sure that there are plenty of Application Notes from the battery manufacturers. I am sure that there are many safety considerations.

I always advise that you study proven commercial designs. Then copy their schematic. Copy their choice of components.

This may not be ethical but it works! Note that many designs are public. The commercial company may be using public designs.

For the purpose of your thesis, I suggest that you explain how the schematic works. I suggest that you explain how you calculated the values of the components. And how / why you chose critical components like batteries, capacitors, cable sizes, ...

Good Luck with your project.

David.

Thank you for your big help david! :) Appreciate all your help. God bless you :)

david_prentice: I am pleased that your TFT is working now. You should always plug the Shield into the Uno. What ID is reported by the graphictest_kbv.ino sketch?

Please run the LCD_ID_readreg.ino sketch again. An ID of 0x0501 is very unusual. Which ID worked best for you?

It is very likely that someone else has the same Display Shield as you. The information would help others.

David.

Hi david… I will run the LCD_ID_readreg.ino later, I also found out that the problem is some ports are not properly connected because of the cover of the arduino uno… I’m at school… but anyway I have another problem… I’m trying to display the rating of a 9V battery with the voltage divider using 3-30kohms and 1-10kohms but I get a rating of 0. This is my code…

#include <Adafruit_GFX.h> // Core graphics library
#include <MCUFRIEND_kbv.h> // Hardware-specific library
MCUFRIEND_kbv tft;

// The control pins for the LCD can be assigned to any digital or
// analog pins…but we’ll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
// #define LCD_CS A3 // Chip Select goes to Analog 3
// #define LCD_CD A2 // Command/Data goes to Analog 2
// #define LCD_WR A1 // LCD Write goes to Analog 1
// #define LCD_RD A0 // LCD Read goes to Analog 0

// #define LCD_RESET A4 // Can alternately just connect to Arduino’s reset pin

// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
// D0 connects to digital pin 8 (Notice these are
// D1 connects to digital pin 9 NOT in order!)
// D2 connects to digital pin 2
// D3 connects to digital pin 3
// D4 connects to digital pin 4
// D5 connects to digital pin 5
// D6 connects to digital pin 6
// D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).

// Assign human-readable names to some common 16-bit color values:

#define BLACK 0x0000
#define BLUE 0x001F
#define RED 0xF800
#define GREEN 0x07E0
#define WHITE 0xFFFF

// If using the shield, all control and data lines are fixed, and
// a simpler declaration can optionally be used:
// SWTFT tft;

unsigned long time;

void setup(void) {

Serial.begin(9600);

}

void loop(void) {
Serial.print("Voltage Rating: ");
time = micros();
int readVal = analogRead(5);
float voltage = (readVal/1024)5;
Serial.println(voltage);
tft.setCursor(2, 2);
tft.setTextColor(WHITE);
tft.setTextSize(2);
tft.println(voltage
10);
}

I got
Voltage Rating = 0 …
Voltage Rating = 0 …
Voltage Rating = 0 …
Voltage Rating = 0 …
Voltage Rating = 0 … in the serial monitor

VD.PNG

First off. Please edit your post to use CODE tags i.e. the select the text, click the icon on top left.

  1. Any TFT program needs to call tft.begin(ID) with the controller ID e.g.
    uint16_t ID = tft.readID();  //identify your controller
    tft.begin(ID);   //configure for the correct controller
    ...
  1. Most Analog read values need to be converted to a human readable form.
    uint16_t readVal = AnalogRead(5);   //read integer value
    float voltage = readVal * (5.0 / 1024);  //scale it to volts

Think about my scaling method. Then look at your statement. Take a pencil and paper and do the calculation yourself. Note that an integer divide always produces an integer result. i.e. it thows away any remainder.

David.

Hi david… I update my code to this…

  #include <Adafruit_GFX.h>    // Core graphics library
#include <MCUFRIEND_kbv.h> // Hardware-specific library
MCUFRIEND_kbv tft;

// The control pins for the LCD can be assigned to any digital or
// analog pins...but we'll use the analog pins as this allows us to
// double up the pins with the touch screen (see the TFT paint example).
// #define LCD_CS A3 // Chip Select goes to Analog 3
// #define LCD_CD A2 // Command/Data goes to Analog 2
// #define LCD_WR A1 // LCD Write goes to Analog 1
// #define LCD_RD A0 // LCD Read goes to Analog 0

// #define LCD_RESET A4 // Can alternately just connect to Arduino's reset pin

// When using the BREAKOUT BOARD only, use these 8 data lines to the LCD:
// For the Arduino Uno, Duemilanove, Diecimila, etc.:
//   D0 connects to digital pin 8  (Notice these are
//   D1 connects to digital pin 9   NOT in order!)
//   D2 connects to digital pin 2
//   D3 connects to digital pin 3
//   D4 connects to digital pin 4
//   D5 connects to digital pin 5
//   D6 connects to digital pin 6
//   D7 connects to digital pin 7
// For the Arduino Mega, use digital pins 22 through 29
// (on the 2-row header at the end of the board).

// Assign human-readable names to some common 16-bit color values:

#define BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define WHITE   0xFFFF


// If using the shield, all control and data lines are fixed, and
// a simpler declaration can optionally be used:
// SWTFT tft;

unsigned long time;

void setup(void) {
   
  tft.reset();

  uint16_t ID = tft.readID();
  tft.begin(ID);  
  
  Serial.begin(9600);

}


void loop(void) {

  for(uint8_t rotation=0; rotation=1; rotation++) {
  tft.setRotation(rotation);
  testText();
  delay(1000);
    
  }
}


  unsigned long testText() {
  tft.fillScreen(WHITE);
  unsigned long start = micros();

  
  Serial.print("Voltage Rating: ");
  time = micros();
  uint16_t readVal = analogRead(5);  
  float voltage = readVal * (5.0 / 1024); 
    
   
  tft.setCursor(0, 0);
  tft.setTextColor(BLACK);  
  tft.setTextSize(2);
  tft.print(" ");
  tft.println(" ");
  tft.println(" ");
    
  Serial.println(voltage);
  tft.setTextColor(BLACK);
  tft.setTextSize(2);
  tft.print("   VOLTAGE RATING :" );
  tft.println(voltage); 
}

I’m now also using 1-30.2kohms and 3-kohms for my voltage divider, found out that the resistances are not exactly 10kohms and 30kohms… I’m now getting this value(attached)… but my input voltage is 9.45V… What must be the problem?

VD.PNG