recorder.ino 803 Bytes
#include <SD.h>
#include <SPI.h>

const int xInput = A1;
const int yInput = A2;
const int zInput = A3;
int setUpTime =0;
File logfile;

void setup() {
  Serial.begin(115200);
  delay(1000);
  if (!SD.begin(4))
  {
    Serial.println("No SD card detected. Insert SD Card"); // No card available? Let us know.
    while(1){
      }
  }
  else{
  logfile = SD.open("data.txt", O_WRITE | O_TRUNC);
  
  }
  setUpTime = millis();
}

void loop() {
  int xRaw = analogRead(xInput);
  int yRaw = analogRead(yInput);
  int zRaw = analogRead(zInput);
  int sum = (abs(xRaw) +abs(yRaw) + abs(zRaw));
  logfile.println(sum);
  Serial.println(sum);
  delayMicroseconds(805);
  //analogWrite(DAC1, sum);
  if(millis()>10000 + setUpTime){
    Serial.println("Recording end");
    logfile.close();
    while(1){}
  }
}