const char* filename="data.txt";
void setup(){
//setup for Serial port
USB.begin();
SD.ON();
// setup the Accelerometer module
USB.println("Setting up Accelerometer...");
ACC.ON();
// waiting for Accelerometer is connected to satellites
while( !ACC.check()) delay(1000);
USB.println("Connected");
}
void loop(){
byte check = ACC.check();
//----------X Values-----------------------
uint8_t x_acc = ACC.getX();
//----------Y Values-----------------------
int y_acc = ACC.getY();
//----------Z Values-----------------------
int z_acc = ACC.getZ();
USB.print("\n------------------------------\nCheck: 0x");
USB.println(check, HEX);
USB.println("\n \t0X\t0Y\t0Z");
USB.print(" ACC\t");
USB.print(x_acc, DEC);
USB.print("\t");
USB.print(y_acc, DEC);
USB.print("\t");
USB.println(z_acc, DEC);
string[0] = (x_acc/1000) + 48;
string[1] = (x_acc/100)%10 + 48;
string[2] = (x_acc/10)%10 + 48;
string[3] = (x_acc/1)%10 + 48;
string[4] = '\0'
SD.appendln("data.txt",":");
SD.appendln("data.txt",string);
SD.appendln("data.txt",":");
SD.appendln("data.txt",string);
SD.appendln("data.txt",":");
SD.appendln("data.txt",string);
USB.println("Write to 'data.txt' ");
}