I'm currently using a project that uses an Arduino Mega 2560 pro. I want to use a micro SD card module and a 2.8 SPI TFT touch display. They both require pins for the SPI bus but I'm not really sure if I can do that. I read that I can use the ICSP pins for another pin. I have yet to receive my display module so I was not able to test it out yet.
I would like to ask if it is possible to use a micro SD card module and TFT SPI 2.8" display connected to one Arduino mega 2560 pro? Possibly how as well if it is complicated?
TFT screens and SD modules can be 3.3V devices. If that I the case with yours, they will need level shifting to interface with the 5V Mega. There are lots of articles on the web that cover level shifting.
One thing to watch out for. Many SD modules come with level shifters on the module. Some of those run the MISO signal through the level shifters. Those level shifters do not handle the MISO signal properly and will not work with other parts on the SPI bus. Try to find SD modules the run the MISO signal straight from the card to the processor (like the Adafruit module). The MISO signal bypasses the level shifters.
Thank you all for your replies! I got a level shifter for the TFT screen. I still have to check if the SD module does not bypass the MISO pin.
One more question:
Do I only need to level shift the SPI pins (MISO, MOSI, SS, SCLK) for the TFT display? While the others can run on 5v from the mega?
If you're reasonably handy, there's a fix if your microSD module doesn't properly let go of MISO. The fix simply connects the MISO header directly to the MISO pin of the SD holder, and cutting the trace from the output of the level shifter to the MISO header. This has the 3.3V output of the SD card driving the MISO pin of the 5V Arduino, but it turns out that that works just fine. The Adafruit microSD module does it that way. So in general, you don't have to level-shift MISO.
Running a 3.3V output into a 5V input can work and almost always works, but the margin for distinguishing a logic "1" is significantly reduced. It's okay for experimental purposes, but it should never happen in a product or project that must be completely reliable. With the reduced margin, any one of a plethora of factors that could randomly change can crash the system.
My project must be completely reliable so I have to shift the voltage. I am also connecting other sensors to the arduino mega 2560 pro namely:
pH sensor
DS18B20 temperature probe
HC-SR04 distance sensor
I am accustomed to running these at 5v, I think most of them will not work on 3.3v so I'll have to stick with level shifting.
With regards to sharing the SPI pins, is there a way to splice a wire so I do not have to use a breadboard? I'm trying to make the project as compact as possible.
Thank you everyone for your answers! They are all really helpful!
May I also ask about the CS/DC pin or the SS pin? I'm rather confused about the three: how to connect them or how to set them up. I read up a little on them but I still cannot figure it out. I read that the SS pin for the mega is D53, but I am not sure how to enable multiple SS pins since I will need three of them. Kindly advise me about the CS/DC pin as well.
I was already able to connect the rest of the TFT SPI 2.8 Display pins to the rest of the SPI bus.
CS (chip select), SS (slave select) are different names for chip select. DC is the pin to select between Data or Command bytecoming on the bus.
The default SPI chip select pin on the Mega is 53, but any pin can be used as a chip select. Libraries will have the facility to change the chip select so that you can have multiple devices on the SPI bus. Usually by specifying the chip select pin in the device constructor.