|
|
发表于 2013-4-3 18:13:00
|
显示全部楼层
楼主,请教下我用是APM2.5 mega2560的板子读取跟你一样的SD卡,但接线,写代码发现没反应!!
引脚接线: SD卡 APM2.5板
MISO ---------> MISO(50)
MOSI ----------> MOSI(51)
SCK -----------> SCK(52)
CS ----------> PB6(12) //这个是随便找个outpin接口用的
SS(53) //文档上说不用要设为输出
代码:
#include <SD.h>
#include <SPI.h>
// On the Ethernet Shield, CS is pin 4. Note that even if it's not
// used as the CS pin, the hardware CS pin (10 on most Arduino boards,
// 53 on the Mega) must be left as an output or the SD library
// functions will not work.// const int chipSelect =4 ;
const int chipSelect = 12;
void setup()
{
Serial.begin(9600);
Serial.print("Initializing SD card...\n");
// make sure that the default chip select pin is set to
// output, even if you don't use it:
//pinMode(10,out)
pinMode(53, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
}
void loop()
{
....
}
错误是在打印“Card failed, or not present”这个信息,就没了!!求帮忙啦,先谢过!!!! |
|