Double allocation of digital pins

Hi all,

I'm stuck with my Arduino project and hope to get some help :slight_smile:

I want to build a project in which based on the ID of an RFID chip certain mp3s are played over a loudspeaker.

I'm using the sparkfun mp3shield. In order to get this thing running on an Arduino Mega I had to use jumpers that connect pins
11 -> 51
12 -> 50
13 -> 52
see e.g. the comments in MP3 Shield - DEV-09736 - SparkFun Electronics
This part is running now without problems.

Then I'm using the RFID reader RFID-RC522 for which I also need pins 50, 51 and 52. When I detach the jumpers from the mp3shield and use them for the RFID reader also this part of my project is running now, i.e. i can read the IDs of my RFID cards.

I'm now wondering how I can run both shields given that they both need to use pins 50, 51 and 52. I understand that these pins are the SPI of the Mega which I guess theoretically should allow me to use the same pins for multiple shields. Is my assumption correct?

Cheers,
Christian

SPI is a bus. Just make sure every device on SPI has its own SS (Slave Select) line and you can have many devices connected to the same three SPI pins.

On a Mega you have indeed 50 (MISO), 51 (MOSI) and 52 (SCK). Standard SS is 53 but you need one of those for each device. Check the driver libraries that come with the respective devices on how to set this.

Not just theoretically, but in fact. Arduino SPI reference.

wvmarle is correct. You list 3 of the four necessary pins. The missing pin (SS or CS in your link, connected to arduino UNO pin 9) is the key to your answer. Use two different UNO pins as CS or SS, each per device.