2869| 0
|
[求助] arduinoSD卡模块识别不到sd卡,可能是什么原因引起的啊? |
连线和代码都没问题,卡的类型和端口选择都没有问题,/* * Arduino SD Card Tutorial Example * * by Dejan Nedelkovski, www.HowToMechatronics.com */ #include <SD.h> #include <SPI.h> File myFile; int pinCS = 53; // Pin 10 on Arduino Uno void setup() { Serial.begin(9600); pinMode(pinCS, OUTPUT); // SD Card Initialization if (SD.begin()) { Serial.println("SD card is ready to use."); } else { Serial.println("SD card initialization failed"); return; } // Create/Open file myFile = SD.open("test.txt", FILE_WRITE); // if the file opened okay, write to it: if (myFile) { Serial.println("Writing to file..."); // Write to file myFile.println("Testing text 1, 2 ,3..."); myFile.close(); // close the file Serial.println("Done."); } // if the file didn't open, print an error: else { Serial.println("error opening test.txt"); } // Reading the file myFile = SD.open("test.txt"); if (myFile) { Serial.println("Read:"); // Reading the whole file while (myFile.available()) { Serial.write(myFile.read()); } myFile.close(); } else { Serial.println("error opening test.txt"); } } void loop() { // empty } 选的2560板子,代码也没有问题,但是显示初始化失败是怎么回事呢 |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed