Go Down

Topic: LiquidCrystal + SD on Mega2560 can't use pins 50-53 (Read 61 times) previous topic - next topic


Hopefully this will save some others some headaches...

When using an SD reader that utilizes pin 4 for CS (maybe any pin, but this is my scenario), it will cause your lcd to act erratic if the lcd utilizes any of pins 50-53.  The interesting thing is that you can have it all hooked up and working one at a time but as soon as you call SD.begin(4) it will cause your lcd to go crazy if any one of it's pins are utilizing any one of the pins 50-53.  After changing all my lcd's pins to 32-37, all is well.  I haven't tested every single pin, but these are the only ones I've ran into issues with besides the obvious known pins that SD utilizes.


besides the obvious known pins that SD utilizes.
Which are in fact, pins 50 to 53, the SPI interface.

What's your point?


Nov 22, 2014, 03:06 pm Last Edit: Nov 22, 2014, 03:09 pm by floresta
One of the advantages of the LiquidCrystal library, which sadly is not only not emphasized but is completely ignored in the tutorial, is the fact that any available I/O pin on the Arduino can be used for any of the signal or data lines required by the LCD.

The idea is that you inventory the pins used by all of the other peripherals in your project, in this case the pins used by the SD reader, and then choose different pins for your LCD.  You then inform the library which pins you are using by means of the LiquidCrystal lcd(...) statement.



Paul__B, my point is that nowhere in the docs for SD was that stated.  The only thing it said was something about pin 53 so I knew to stay away from that, but that's it.  Also, my SD shield is connected directly to pins 1-4, not 50-53 so are these mirrors of each other?  The spi docs state that it's pins 1,3,4 OR 50-52, not that both are active when either is used.  I apologize if it's a stupid question, but the reason for my post was to save someone else the same headache as I went through as not everyone is an expert of the pin mappings of the arduino or even hardware experts as the arduino was meant for an easy way for non experts to get into hardware programming which is obviously where i'm at...

floresta, I was well aware of that fact and that is why I had just moved it to the last pins figuring it would be out of the way of everything but apparently I was wrong even though I was inventorying which pins I used..

Anyway, thanks to both of you for responding, it's definitely appreciated!


Haven't an SD "shield" (only modules), so I can't say about the documentation but it is definitely not connected to pins 1 to 4 as pin 1 is for starters, the serial interface.

{Goes and ferrets out own 2560 to look at, then pighixxx.}

So, here is the 2560:

And here is the UNO:

It is true that the SPI ports on the UNO, for which the shield is designed, are digital pins 10 to 13 - which are indeed the "last four" - or the ICSP header.  Unless the SD shield mates with the SPI header, it will not natively operate with the 2560 as it is clearly designed (as are many shields) for the UNO.

Go Up