diff options
| author | robosoccer <robosoccer@mendelcollege.nl> | 2025-03-20 15:20:27 +0100 |
|---|---|---|
| committer | robosoccer <robosoccer@mendelcollege.nl> | 2025-03-20 15:20:27 +0100 |
| commit | 20c32f0508838361ecf899dfc6f5f3b70abede8a (patch) | |
| tree | a38d7eac4d7de697b5a000b8986ec9f49b7a5e96 /CODE/debug/IR/communication/rx_teensy/rx_teensy.ino | |
| parent | 7e9328765f41a6055a722285678bc6bc09963c07 (diff) | |
| download | robotica-20c32f0508838361ecf899dfc6f5f3b70abede8a.tar.gz robotica-20c32f0508838361ecf899dfc6f5f3b70abede8a.zip | |
things
Diffstat (limited to 'CODE/debug/IR/communication/rx_teensy/rx_teensy.ino')
| -rw-r--r-- | CODE/debug/IR/communication/rx_teensy/rx_teensy.ino | 36 |
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); } |
