SD/Arduino Change default pins

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
IDONTNODOU
 
Posts: 3
Joined: Tue Feb 18, 2020 10:16 pm

SD/Arduino Change default pins

Post by IDONTNODOU »

I purchased the SD Card Shield (Adafruit PN: 254). The default connection pins (Mega 2650 R3) are 10, 11, 12 and 13. I have another device that is also hard coded to use pins 10 and 11.

I have browsed nearly every code file associated with the SD cards and SPI functions, but don't see how I am to change these default pin locations.

Is it possible? ...and if so, which library or file needs to be altered? I would like then to be moved to pins 24, 25, 26 and 27 (if possible).

I thank you in advance for your reply!

Ken

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: SD/Arduino Change default pins

Post by adafruit_support_bill »

In your call to SD.begin, specify the pins you want to use. Pins are specified in the following order:

CS (Chip Select), MOSI, MISO, SCK

Code: Select all

SD.begin(24, 25, 26, 27)

User avatar
IDONTNODOU
 
Posts: 3
Joined: Tue Feb 18, 2020 10:16 pm

Re: SD/Arduino Change default pins

Post by IDONTNODOU »

Thanks for your quick reply... I didn't see that call in the examples I looked at (I must have just overlooked them, I assume they are there.) I felt they were hard-coded within the libraries.

THANKS!

Ken

User avatar
IDONTNODOU
 
Posts: 3
Joined: Tue Feb 18, 2020 10:16 pm

Re: SD/Arduino Change default pins

Post by IDONTNODOU »

Bill:

Which library are you using that accepts that 'begin' code? I have tried that several times trying the different libraries I have found for SD readers, and none of them accept 4 arguments.

....Still trying to get any card or library to actually read/write. Not having any success.

Any additional information will be appreciated!

Ken

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: SD/Arduino Change default pins

Post by adafruit_support_bill »

This is our fork of the SD library that supports alternative pins: https://github.com/adafruit/SD
Supposedly, this functionality has also been integrated into the default Arduino library. But the Arduino documentation does not say anything about that.
https://www.arduino.cc/en/Reference/SDbegin

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”