recorder.ino
803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#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()>15000 + setUpTime){
Serial.println("Recording end");
logfile.close();
while(1){}
}
}