summaryrefslogtreecommitdiff
path: root/CODE/debug/IR/communication/rx_teensy/rx_teensy.ino
diff options
context:
space:
mode:
Diffstat (limited to 'CODE/debug/IR/communication/rx_teensy/rx_teensy.ino')
-rw-r--r--CODE/debug/IR/communication/rx_teensy/rx_teensy.ino36
1 files changed, 30 insertions, 6 deletions
diff --git a/CODE/debug/IR/communication/rx_teensy/rx_teensy.ino b/CODE/debug/IR/communication/rx_teensy/rx_teensy.ino
index 7dca76d..8e1ecfa 100644
--- a/CODE/debug/IR/communication/rx_teensy/rx_teensy.ino
+++ b/CODE/debug/IR/communication/rx_teensy/rx_teensy.ino
@@ -1,17 +1,41 @@
-int incomingByte = 0; // for incoming serial data
+String tlocd = "";
+String locd = "";
+bool readloc = false;
+unsigned long datatime = 0;
void setup() {
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
- Serial1.begin(9600);
+ Serial2.begin(9600);
}
void loop() {
// send data only when you receive data:
- if (Serial1.available() > 0) {
- // read the incoming byte:
- incomingByte = Serial1.read();
+ if (Serial2.available() > 0) {
+ datatime = millis();
+ byte byteRead = Serial2.read();
+
+ if(byteRead == 's'){
+ tlocd = "";
+ 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(incomingByte));
+ Serial.print(char(byte byteRead));
}
+
+ delay(111);
}