micro-SD and unavailable SPI pins, and whether Arduino Yun will help


I currently have an Arduino Mega 2560, which is using the TLC5940 library: (Google Code Archive - Long-term storage for Google Code Project Hosting.), which makes use of some of following pins:

(MOSI) (SCK) (OC1A) (OC1B) (OC2B)

These or some of these are 'SPI' pins, and any sort of SD shield seems to need at least MOSI and SCK for its own purposes.

I want to use the SD to store some animations, which I'll send to my TLC5940.

So I'm wondering if the Arduino Yun might be what I need? It has a micro-SD input - does anyone know if this microSD uses up SPI pins? Or can I use the microSD and still be able to use the SPI pins for the TLC5940 output?

Or is there any SD shield that doesn't require my using up the SPI pins?


If I understood correctly, you need to realize SPI is a bus - you can connect multiple devices. Your LED driver is not "using up the SPI".

MOSI, MISO and SCLK are common to all devices. There will be one SS output for each device, and you will set all the devices to LOW, and the one you want to talk to to HIGH (or was it the other way around? :roll_eyes:).

It's the other way round :slight_smile:


Ok thanks,

So I'm using an Arduino Mega, which has:
Pin 50 - MISO
Pin 51 - MOSI
Pin 52 -SCK
Pin 53 - SS

My SD shield uses all 4 of them.
And my LED display uses 51 (MOSI) and 52 (SCK).

So the TLC doesn't have an SS associated with it. So if I set pin 53 HIGH, it will use the SD, and if it's LOW, then the LEDs? How does it work when one of the devices is just using the SPI pins but doesn't specify an SS pin?

The SD shield is active when 53 is low.
When high, some other device can do SPI transfers by pulling its SS pin low.
If the LED display is only connected to MOSI & SCK, then it will appear to randomly change when SD transfers are occurring. That's the way SPI works - if a device's SS line is inactive, it ignores what's happening on SCK, MISO, and MOSI.