MCUfriend TFT LCD pin re-assignment

I have recently bought a 3.5" TFT LCD (from Ebay) for an Arduino UNO, however I find that it uses nearly all the available UNO pins and in particular most of the analogue pins, 4 of which I was hoping to use as analogue inputs. As I have no intention of using the SD card slot, would it be possible to transfer 4 of the LCD control lines to the pins currently used by the SD card connector?

I have the display up and running using MCUFRIEND_kbv and UTFTGLUE.h, but when I try to re-assign the LCD pins using:

#define RS 12 //A2
#define WR 11 //A1
#define CS 14 //A3
#define RST 13 //A4
#define RD A0

UTFTGLUE myGLCD(0x9488,RS,WR,CS,RST,RD);

the display still works, implying that something else is controlling the pin assignment.

Physically rewiring the pins looks fairly straightforward, and even though I have rewired the RST from A4 to 13, I still can't use A4 as an anologue input - as it still appears to be assigned to something.

How can i change this, please?

The constructor arguments are all dummies. MCUFRIEND_kbv is designed to run with the shields that God has designed for you.

If you really want to hack your shield for different pins, you need to write a SPECIAL for the new pin wiring.
If you tell me the wiring, I will write the SPECIAL for you.

Why do you want 4 ADC channels?
It is very easy to remove the LCD_RST pin and use a Software Reset. This gives you A4, A5.
If you have a clone Uno, most of these have A6, A7.

Hence 4 ADC channels.

David.

David: Thanks for replying.

I need 4 ADCs because I'm making a 4 in one dashboard guage to display Oil pressure, Oil Temperature, Fuel Pressure and Fuel level. I've written the display part, I just need to get the (analogue)data into it.

I have already removed the LCD_RST pin, but A4 is still not functioning correctly, which is why I thought there must be something else in the software assigning pins. A5 is free and working correctly.

I have a real UNO, so only have A0-A5.

Are you saying that the LCD pin allocations are defined in MCUFRIEND_kbv.cpp? If so, I can't see where.

Ideally I would like these assignments:

#define LCD_RS 12
#define LCD_WR 11
#define LCD_CS 14
#define LCD_RST 13
#define LCD_RD A0

George

From the how_to file:

  1. The constructor takes no arguments (because it only works with these shields)

  2. The examples are the standard Adafruit ones. You can see my edits by searching for "kbv"

  3. Any Adafruit sketch should work with the MCUFRIEND_kbv constructor() but should allow extra ID values
    An Adafruit constructor(cs, rs, wr, rd, rst) IGNORES any arguments. i.e. it only uses the shield control pins

The only reason for allowing arguments in the constructor is for convenience when porting from Adafruit or UTFT. Since the library is designed for shields, the wiring is KNOWN. Hence there is no point in having arguments.

Of course you can hack your shield to pieces if that is what you enjoy doing.
I suggest that it is easier / cheaper to buy a SMD Uno clone.

But if you want to perform surgery on your shield:

  1. you test your surgery with the LCD_ID_readreg sketch.
  2. I will post a SPECIAL for you.

David.

What do you mean by a SPECIAL?

Pin wiring for standard Shields is in the mcufriend_shield.h file.
Pin wiring for non-standard SPECIAL wiring is in mcufriend_special.h

This library is intended to be used with Mcufriend Uno Shields plugged into regular Arduino header sockets.

You do not need to configure anything. It will work with any controller Shield on any regular Arduino.

Yes, it uses most of the header pins on a Uno.
A Mega2560 or Due has got plenty of spare pins.

David.

David: Thanks for your help - I've decided to use a Mega2560 instead as it has all the analogue inputs I need and works fine with the TFT LCD shield.

George

Just out of interest, I went back to the UNO as it is a neater solution.

I transfered 4 of the LCD control signals on the mcufriend TFT from the analogue pins to the digital pins used by SD card, and then wrote the new pin assignments into a new section in mcufriend_special.h.

That frees up 4 more analogue inputs and works well - updating the display faster than the mega2560 for some reason.

I guess the TFT rewiring could be done with an extra shield too.

I have made several "HOME_MADE" Protoshields. e.g. to put the data bus on PORTC of a Mega2560.
This works very fast.

The default Shield pin mapping for a Mega2560 is random. Hence the slow speed when you have to map all the bits differently.

I strongly advise using ready-made Shields. Mechanically and electrically reliable.

If you want to rearrange pins, I suggest that you do this with a Protoshield. i.e. solder all the custom wiring. Keep the mechanical connections.

David.

Hi David. I am stacking a Arduino Motor Shield R3 onto a Arduino Uno R3, and then on top of that I am using the 3.5" Kuman touchscreen display with shield for the Uno. I want to use this setup to control a fan and a vent motor with the touchscreen. From what I can tell digging though the code (pin_magic.h) the tft is using the following digital pins: 4, 6, 7, 8, 9, 10, 11, 13. According to the spec sheet for the motor controller, it uses digital pins 3, 11, 12, 13. Pins 11 and 13 are common between the two shields. The various .h and .cpp files that configure the pins for the tft are a bit beyond my skill level at this point. What I would like your input on is whether a 'specal' could be used to reassign pins 11 and 13 for the TFT to pins 2 and 5, perhaps, in order to allow 11 and 13 to be used by the motor shield. Or, alternatively is there a methodology by which pins 11 and 13 could be shared between the two boards? Thanks in advance for your thoughts.

Please post a link to the actual shield that you have.
Make sure that photos accurately represent your device.

I need to see pcb side.

David.

See attached. Thanks. Digital pin 11 on Arduino is used by SD_DI on the tft shield, and pin 13 is used by SD_SCK on the shield. I’m not using the SD slot on the screen.

The wiring is Mcufriend-style. I suspect it has an ILI9481 controller.

This should work with Adafruit_TFTLCD or with MCUFRIEND_kbv libraries.

You edit pin_magic.h for Adafruit
You edit mcufriend_special.h for MCUFRIEND_kbv

Neither task is easy for a beginner.

Personally, I would not interfere with the display shield.
If you are not using the microSD, you have pins 10-13, A5 available. i.e. 4 digital, 1 analog.

I would wire the motor, sensors etc to these pins. I would use PIN_CHANGE interrupt on pin #10 instead of INT1 (i.e. digital #3 pin)

David.

Thanks for the information. If you would indulge me just a bit longer. I have to use Digital pins 3 and 11 for the motor shield as it requires PWM on those pins to control motor speed. I have some studying to do regarding interrupts. Generally speaking, why would you use PIN_CHANGE interrupt on pin 10 instead of pin 3?

david_prentice:
The constructor arguments are all dummies. MCUFRIEND_kbv is designed to run with the shields that God has designed for you.

If you really want to hack your shield for different pins, you need to write a SPECIAL for the new pin wiring.
If you tell me the wiring, I will write the SPECIAL for you.

Why do you want 4 ADC channels?
It is very easy to remove the LCD_RST pin and use a Software Reset. This gives you A4, A5.
If you have a clone Uno, most of these have A6, A7.

Hence 4 ADC channels.

David.

david_prentice:
If you really want to hack your shield for different pins, you need to write a SPECIAL for the new pin wiring.
If you tell me the wiring, I will write the SPECIAL for you.

Please, I use my mcufriend display in Arduino Mega 2560, but I need some more analog pins for my project (sensors basically). How can I do? I would like wiring the actual pins A0 A1 A2 A3 A4 A5 to any digital pins, Digital 48 to 53 for example ... anyone.

I try to edit mcufriend_special.h but nothing happens ... I try to disconnect A5 and all is working, but I need some free analog pins more ...

I you tell me the steps it would be amazing ... o any post, forum, tutorial or similar to do it.

My display is ID=0x9488 and the arduino is a Mega 2560 clone. I use mcufriend_kbv 2.9.8 library

Thanks very a lot to much :slight_smile:

hi David,
in reply #1 you say:
"It is very easy to remove the LCD_RST pin and use a Software Reset. This gives you A4, A5."
how can this be achieved? i couldn't find the solution in the other posts.

i've used a prototype shield in between the tft and mega, and connected the reset pin to arduino reset.
screen works this way but the data from A4 is not usable.
i don't need reset because it's a portable device.

thanks for all your posts!

greetings Maikel

The Mega2560 has got many GPIO pins.

What do you want A4 for ?
The Mega has still got 10 unused Analog pins.
The Mega uses different pins for I2C.

Personally, I would just use the shield as-is. Ok, the Uno shield is fairly slow on a Mega but it does work out of the box. Sensible program design should make the speed acceptable.

If the speed is really critical, either buy a Mega TFT shield or run the Uno shield on a Due.

David.

hi David,

thx for the quick reply!

the speed is fine, and i've already got several mega's and several of these VMA412 2,8" tft's with ILI9341 chip (according to the package suitable for uno and mega) link: VMA412: 2.8 INCH TOUCH SCREEN FOR UNO/MEGA DEVELOPMENT BOARD – Velleman – Wholesaler and developer of electronics

i need 12 analog inputs and do not need the reset, so i thought to disable the reset.
in post #1 you sayd it was easy to remove. but how can i do that?

Your Velleman shield is just a "Blue 2.8 inch Mcufriend" with white paint.

Of course it is wise to use the screen that is in your hand. But even better to think before buying in the first place.

I have written several times "how to" snip LCD_RST pin and solder a 10k pullup to the snipped pin.
Google "Mcufriend LCD_RST I2C"

Likewise I have described home made Adapter with Protoshield. You cut the track between male and female header pin. Hand-wire your alternative mapping. Very robust mechanically and electrically.

David.