blob: f135d8745de9ac51db689837ed0955bc5cfd3c32 (
plain)
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
|
String tlocd = "";
String locd "";
String irs1 = "";
String irs2 = "";
String am1 = "";
String am2 "";
bool readloc = false;
unsigned long datatime = 0;
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
Serial2.begin(9600);
}
void loop() {
// send data only when you receive data:
if (Serial2.available() > 0) {
datatime = millis();
byte byteRead = Serial2.read();
if(byteRead == 's'){
tlocd = ""; 0
readloc = true;
}
else if(byteRead == 'e'){
readloc = false;
locd = tlocd;
}
else if(readloc == true){
tlocd += (char)byteRead;
}
else{
if(millis() - datatime > 5000){
Serial.println("Err no data recieved for 5 sec");
locd = "999";
}
Serial.println(locd);
}
// say what you got:
Serial.print(char(byte byteRead));
}
delay(111);
}
|