-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgps_logger.pde
66 lines (58 loc) · 1.45 KB
/
gps_logger.pde
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <SD.h>
// This code still produced data in NMEA.
// to make it able to produce data in SirfIII:
// Format: $PSRF100,<protocol>,<baud>,<DataBits>,<StopBits>,<Parity>*CKSUM<CR><LF>
// <protocol> 0=SiRF Binary, 1=NMEA, 4=USER1
// <baud> 1200, 2400, 4800, 9600, 19200, 38400
// <DataBits> 8,7. Note that SiRF protocol is only valid in f8 data bits
// <StopBits> 0,1
// <Parity> 0 = None, 1 = Odd, 2 = Even
//
// Example : Switch to SiRF Binary Protocol at 9600,8,N,1
// $PSRF100,0,9600,8,1,0*0C,<CR><LF>
const int chipSelect = 10;
void setup()
{
Serial.begin(9600);
pinMode(10, OUTPUT);
if (!SD.begin(chipSelect)) {
return;
}
}
void loop()
{
// make a string for assembling the data to log:
char index = 0;
char temp = 0;
String dataString = "";
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
/*
while(Serial.available())
{
File dataFile = SD.open("datalog.txt", FILE_WRITE);
if(dataFile)
{
temp = Serial.read();
dataString += String(temp);
dataFile.print(dataString);
dataString = "";
dataFile.close();
}
}
*/
File dataFile = SD.open("datalog.txt", FILE_WRITE);
if(dataFile)
{
while(Serial.available())
{
temp = Serial.read();
dataString += String(temp);
index++;
if(index>200)
break;
}
dataFile.print(dataString);
dataFile.close();
}
}