完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
我在 Arduino IDE 上使用 ESP8266 进行一个项目,该项目需要使用 SD 模块从加速度计 (MPU6050) 高速写入数据(每 0.01 秒写入 3 轴的数据),但我有一个问题。由于我无法弄清楚的原因,SDFat 库没有看到工作,我只是在尝试库本身附带的示例,甚至不编译。
示例代码: 代码:全选#include //#include #include "SdFat.h" SdFat SD; #define SD_CS_PIN SS File myFile; void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } Serial.print("Initializing SD card..."); if (!SD.begin(SD_CS_PIN)) { Serial.println("initialization failed!"); return; } Serial.println("initialization done."); // open the file. note that only one file can be open at a time, // so you have to close this one before opening another. myFile = SD.open("test.txt", FILE_WRITE); // if the file opened okay, write to it: if (myFile) { Serial.print("Writing to test.txt..."); myFile.println("testing 1, 2, 3."); // close the file: myFile.close(); Serial.println("done."); } else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); } // re-open the file for reading: myFile = SD.open("test.txt"); if (myFile) { Serial.println("test.txt:"); // read from the file until there's nothing else in it: while (myFile.available()) { Serial.write(myFile.read()); } // close the file: myFile.close(); } else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); } } void loop() { // nothing happens after setup } |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
468 浏览 0 评论
984 浏览 0 评论
1707 浏览 0 评论
请问一下我想用ESP8685直接替换ESP8266而不用写程序,可以让ESP8685直接通过之前ESP8266的外挂的flash运行程序吗
1364 浏览 1 评论
1253 浏览 1 评论
为blufi_device设置自定义名称,但是无法修改,为什么?
1286浏览 4评论
请问ESP32-S2-WROOM怎么获得ESP32-S2外接FLASH的唯一序列号?
943浏览 3评论
2378浏览 3评论
ESP-IDF的VScode插件的build按钮点击会报错的原因?
2565浏览 3评论
ESP-Jumpstart例程中第5个工程:5_cloud连接报错是哪里的问题?
1071浏览 2评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-12 05:23 , Processed in 0.642005 second(s), Total 71, Slave 54 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
512
