I have a TFT LCD display which comes with a shield for arduino uno (like this one https://www.amazon.de/-/en/Hailege-ILI9341-240X320-Display-Arduino/dp/B07YKN1C2Z)
I am using the SPFD5408_Adafruit_TFTLCD.h library which is working fine with it.
But the issue is that the LCD shield is using the analog ports A0-A4 for the LCD_CS,CD,WR,RD and RESET.
In my project, I have 4 sensors that require using the analog ports, and the LCD is using them and as you know in arduino UNO I only have 6 analog ports.
Is there a way to use the digital ports 10,11,12,13 for the LCD display or maybe is there any other library that I can use which permit me to use the digital ports instead of the analog ones.
Thank u.
Can’t view the Amazon page on this phone, but if the display has an SD card interface, you might be able to disconnect that and use those pins for the display. You would need to modify the library files.
This display has a resistive touch overlay also connected to the analog pins. Needs to be on those pins if you want to use touch (no touch controller.
It doesn't have an SD card holder.
Finally had a look at the link the OP posted, the display clearly has an SD card holder and four pins dedicated to the SD card.
The A4 connection on this type display is a reset line, that can easily be moved to the reset pin on the arduino, or just tied HIGH and rely on a reset when applying power. (I've done that in order to use the I2C bus along with a similar display).
Using a Nano (atmega328 version) would give you two additional analog inputs, with no changes to the code or wiring.
Hi David,
I already disconnected the SD card pins and tried to use them instead of the analog ports.
I used an example from Electronics Eternity youtube channel making the TFT works without library, but they also use the analog ports in their example. I modified their code and the TFT worked fine with digital pins, but as you know using library is far simple, as all functions are already defined.
Modifying the library is a tough option, I will check if I can do it with my little experience.
Thank you.
Hello,
If the touch require the analog ports, then the only option that I have now is what @kolaha suggested, which is using the arduino mega instead.
But how it comes the analog ports are used for the LCD and for the touch at the same time, and I can't use the same digital ports for the same functionality.
Thank u anyway for your reply.
You may be lucky, the library has two constructors, one for the default shield pinout, and one for the breakout board where you define the CS, CD, WR, RD, and RST pins.
You do need to be careful that the USE_ADAFRUIT_SHIELD_PINOUT define line is commented out in the SPFD5408_Adafruit_TFTLCD.h file. (this seems to be the default)
// **** IF USING THE LCD BREAKOUT BOARD, COMMENT OUT THIS NEXT LINE. ****
// **** IF USING THE LCD SHIELD, LEAVE THE LINE ENABLED: ****
// *** SPFD5408 change -- Begin
//#define USE_ADAFRUIT_SHIELD_PINOUT 1
// -- End
Should be ok, the touch screen only needs two analog pins, and you needed four for your sensor.
The analog pins for the touchscreen are shared with the pins for the display. Whenever you read the touchscreen, it is necessary to immediately set the pins back to output mode for use by the display library.
Hi David,
Thank you for your help.
What are the two pins that require to be analog, as on the shield there is no dedicated ports for the touch. I have only the CS, CD, WR, RD, and RST pins, in addition to the digital and SD pins.
It's good idea to connect the RST pin to the reset pin on the arduino.
But still I have to update the library, no?
Thank you David,
do you mean that uncommented the //#define USE_ADAFRUIT_SHIELD_PINOUT 1
will makes me define the ports needed to be used as digital pins for the LCD.
But I still need to know what are the two pins that require analog and used by the touch screen to connect them.
Leave that line commented out, then use the constructor where you explicitly define the cs, cd, wr,rd, and rst pins. If the touchpad is on A1 and A2, leave the digital pins for the display wired to those, and use A0, A3, A4, and A5 for your sensors.
Yes, I already did a lot of tests including the touch and everything is working fine with that library. as per the library that I am using, the A1 is the LCD_WR and A2 is the LCD_CD. Does that make sense.