Arduino wont open SD card file
this first time using sd card reader. need log distance measurements hc-sr04 wont open file on sd card. suggestions? ill upload code.
code: [select]
#include <newping.h>
#include <sd.h>
#include <spi.h>
#define trigger_pin 6
#define echo_pin 7
#define max_distance 200
#define pingspeed 1000
newping sonar(6,7,65);
#define chipselect 4
file myfile;
void setup() {
serial.begin(115200);
serial.println("initializing sd card");
if (!sd.begin(4)) {
serial.println("it aint working");
return;
}
serial.println("initialization works");
pinmode(10,output);
}
void loop() {
ping();
delay(5000);
sdcard();
}
void ping(){
delay(50);
int us=sonar.ping();
serial.print("ping: ");
serial.print(us/us_roundtrip_cm);
serial.println("cm");
}
void sdcard() {
myfile = sd.open("ultra.txt", file_write);
if (myfile){
int us=sonar.ping();
myfile.println(us/us_roundtrip_cm);
myfile.close();
}
else {
serial.println("error in opening file");
}
}
i found problem: using 32gb sd card , arduino can't write big of card apparently.
Arduino Forum > Using Arduino > Storage > Arduino wont open SD card file
arduino
Comments
Post a Comment