1.8 SPI TFT 128*160 interface with Arduino UNO R3

Go To Last Post
19 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This is a simple code to display hello world on tft lcd.

 

// include TFT and SPI libraries
#include <TFT.h>  
#include <SPI.h>

// pin definition for Arduino UNO
#define cs   10
#define dc   9
#define rst  8


// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

void setup() {

  //initialize the library
  TFTscreen.begin();

  // clear the screen with a black background
  TFTscreen.background(0, 0, 0);
  //set the text size
  TFTscreen.setTextSize(2);
}

void loop() {

  //generate a random color
  int redRandom = random(0, 255);
  int greenRandom = random (0, 255);
  int blueRandom = random (0, 255);
  
  // set a random font color
  TFTscreen.stroke(redRandom, greenRandom, blueRandom);
  
  // print Hello, World! in the middle of the screen
  TFTscreen.text("Hello, World!", 6, 57);
  
  // wait 200 miliseconds until change to next color
  delay(200);
}

 Only backlight glows but nothing gets displayed. I checked with the connections. Where is the issue?   

This topic has a solution.

First Fail & then succeed, this is what Engineering teach me.

Last Edited: Fri. Feb 7, 2020 - 05:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The TFT library is deprecated.   But it will probably still work.

 

Please post a clear photo of your wiring that shows the Uno connections and the Display connections.

I can identify most 1.8 inch displays from the pcb colour and layout.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
The TFT library is deprecated.

Not mentioned in the documentation:  https://www.arduino.cc/en/Reference/TFTLibrary

 

What's the recommended replacement ?

 

@ pos11 - have you tried any of the examples shown on that page?

 

Please post a clear photo

+1

 

For instructions, see Tip #1 in my signature, below (may not be visible on mobile)

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have used one side of the breadboard to connect VCC & GND.

I have tried with Adafruit ST7735 & GFX library still the issue persists. 

Attachment(s): 

First Fail & then succeed, this is what Engineering teach me.

Last Edited: Thu. Feb 6, 2020 - 11:31 AM
This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You have wired to the SD Card holder.   Put an SD in there.  And run SD examples.

 

Since you want the TFT,  move :
VIOLET from MOSI to SDA
GREEN from SCK to SCL

 

The TFT examples should work 100%.

 

I suggest that you install Adafruit_ST7735 and Adafruit_GFX via the IDE Library Manager.

Run all the Adafruit_ST7735 examples.

 

When you have the display working 100%,  we will show you how to use the SD.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The display is working now. Thanx .

 

I have some queries:

1. Why we are not connecting tft SDA pin to UNO SDA pin, tft SCL pin to UNO SCL pin? 

 

 I have SD card of smaller size which will not fit in this one. I have another tft lcd where I can use that sd card. How can I use the sd card to display imgs using the other tft lcd given in the attachment.

 I am sending the screenshot of other tft lcd module.

 

Attachment(s): 

First Fail & then succeed, this is what Engineering teach me.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Common names for data pins are : SDI, SDO, DI, DO, SDA, ..., MOSI, MISO

Common names for clock pins are : SCK, SCL, ...

Common names for data-command pins are : DC, A0, ...

 

SDA generally means bidirectional data.

 

I2C uses Two-Wire i.e. SDA, SCL

 

SPI uses Three Wires i.e. MOSI, MISO, SCK (and individual CS)

 

Your ST7735 has a bidirectional data line (SDA).   You have to bit-bash for SPI on a single bidirectional pin with an AVR.   Other makes support this mode in hardware.

Your SD card uses separate SDI, SDO pins.

 

Your Blue display requires 3.3V logic.   The Uno has 5V logic.   The ST7735 datasheet specifies 3.3V but in practice the ST7735 is forgiving.

Your Red display has a 5V to 3.3V level shifting buffer chip.   It works legally with the ST7735.   However it prevents you reading the ST7735 registers or Graphic Memory.

 

David.

Last Edited: Thu. Feb 6, 2020 - 01:33 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pos11 wrote:
The display is working now.

laugh

 

Time to mark the solution, then - see Tip #5.

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Both the tft module has touchscreen or not?

First Fail & then succeed, this is what Engineering teach me.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pos11 wrote:
Both the tft module has touchscreen or not?

Don't the product details tell you that?

 

That's a new question - so start a new thread if you can't find out from the supplier!

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Neither the Blue nor the Red display has a Touch panel.

 

Very few 1.8 inch screens do.   You would need tiny pointy fingers.

 

I disagree with Andrew.    It seems wise to ask questions about the same displays on the same thread.

 

In an ideal world the shopkeeper would know about the items that she is selling.

In practice most Chinese Ebay shops sell lingerie.   With the occasional TFT display.

I doubt if she knows about electronics.    I hope that she understands lingerie.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I checked the datasheet where it's not mentioned that it has touchscreen but the same model in some websites show it has a touchscreen. So I am unable to figure out?

First Fail & then succeed, this is what Engineering teach me.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

pos11 wrote:
I checked the datasheet

Which datasheet, exactly ?

Note that the touch part could simply be an overlay - so both the display itself and the controller chip may be totally oblivious to it

 

the same model

How do you know it's the same ?

Lots of displays look alike - but may have different components.

And, again, a touch sensor may just be an add-on to the same basic module.

 

 

So I am unable to figure out?

Does yours have any connections for a touchscreen?

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My advice is:  post a link to the actual item that you have bought.  e.g. Ebay sale

 

Study the sale description carefully.

They have photos of an item that is accurate.   Their "written description" is often complete rubbish.

Does every photo match the item on your desk?

We need to see the pcb.

 

If not,  either describe the visual differences or post your own photo of the pcb.

 

WE can identify most displays.   Probably better than the shopkeeper.

 

but the same model in some websites show it has a touchscreen.

Please post a link to this website.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First Fail & then succeed, this is what Engineering teach me.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Neither of those say anything about a touch screen.

Jim

 

 

(Possum Lodge oath) Quando omni flunkus, moritati.

"I thought growing old would take longer"

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


The 2nd link says, "ili9225"

 

Found at random by googling "ili9225 touch"

https://www.ebay.co.uk/itm/2-2-TFT-Touch-Display-176x220-ILI9225-or-RM68130-compatible-with-Arduino-etc-/263906332211

 

You can see that the touch screen is an overlay on the LCD itself - there are 2 separate flex connectors

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The OP was originally discussing a Blue 128x160 display #4 and a Red 128x160 display #6.   Both look like ST7735.  Neither had a Touch panel.

 

ILI9225 is 176x220 controller.   The Red SPI display in the OP's link #15 has no Touch Panel.

But the picture in Andrew's message #17 shows a 3.3V Red Parallel display with Resistive Touch Panel.

 

I have examples of both SPI and Parallel Red 176x220 displays.

 

Life is much simpler if you provide a link to your display hardware in your Original Post.   It saves us having to guess.

The pcb in #15 link is different to the photo in #6.

 

David.

Last Edited: Mon. Feb 10, 2020 - 10:30 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you for helping me to figure out the touchscreen. I any way get help from you guys even for small issues.

First Fail & then succeed, this is what Engineering teach me.