I'm facing an issue connecting a 128x160 TFT SPI display to my Arduino Uno due to limited available pins. The only free pins I have are:
D0 (RX) and D1 (TX)
D10
D13
A5
Since I ran out of available pins, I decided to use the PCF8574 module to add extra GPIO pins via I2C. This way, I can free up SPI pins for other components and still control the TFT display.
I wired it like this:
PCF8574 SDA β A4 (SDA on Arduino)
PCF8574 SCL β A5 (SCL on Arduino)
PCF8574 pins P0-P4 for TFT control (SCK, SDA, DC, RESET, CS)
However, the screen is not displaying anything. Could you suggest any improvements to the wiring or code? I'd appreciate any help!
How are you driving the PCF8574 P0-P4 pins? Did you write code to simulate an SPI interface on the PCF8574? Are there timing requirements on the display that may be a problem with the PCF8474?
I moved your topic to an appropriate forum category @jawad_r7 .
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
It can be done. Whether or not it is practical depends. Here is some code I wrote to run a MAX7219 via a PCF8574. Ignore about 80% of it (related to the MAX7219) and look at the functions with spi in the name.
Use the PCF8574 to drive these two devices, freeing up your SPI pins. Also, you gain another 6 possible I/Os (and you can move other devices there to free up pins for DC, CS & RESET on Arduino pins if you like).
The display I am using is a 1.8β TFT. Initially, I wired it as shown in the photo. My question is: to avoid adding an extension module (which I canβt use because only the A3 analog pin is still available on my Arduino Uno), can I connect the screen to the following pins: D1, D10, D13, and A3?
If it is possible to use these pins, how should I wire them correctly?
Here the code that work before when I tested the display :
*
* Rui Santos
* Complete Project Details https://randomnerdtutorials.com
*/
// 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);