首页 文章

卡失败或没有出现Arduino Mega

提问于
浏览
0

我正在尝试读取和写入SD卡的数据,但在代码的开头我错误卡失败或没有呈现 . 我更改了为Arduino Uno编写的示例代码中的引脚,但仍然给出了相同的错误.I我正在使用Arduino Mega 2560.How我可以解决这个问题吗?我的代码在这里:

#include <SD.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 = 53;

void setup()
{
 Serial.begin(9600);
 Serial.print("Initializing SD card...");
 // make sure that the default chip select pin is set to
 // output, even if you don't use it:
 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()
 {

 }

1 回答

  • 0

    请添加:

    digitalWrite(53, HIGH);
    

    如果它很低,Wiznet芯片会破坏SPI总线 . (More details)

相关问题