diff options
| author | Abel Tim <abel.tim.t@gmail.com> | 2025-03-23 16:33:05 +0100 |
|---|---|---|
| committer | Abel Tim <abel.tim.t@gmail.com> | 2025-03-23 16:33:05 +0100 |
| commit | 6b328bb4ca0184dc39f0184d1ad2f47b46e5d6d7 (patch) | |
| tree | dae91189524571de504d01f655e7a953d6551b54 /code/debug/communication/rx/rx_decode_teensy/src/main.cpp | |
| parent | 59abac3480502b90c4cff17625ba29329dc461bf (diff) | |
| download | robotica-6b328bb4ca0184dc39f0184d1ad2f47b46e5d6d7.tar.gz robotica-6b328bb4ca0184dc39f0184d1ad2f47b46e5d6d7.zip | |
serial
Diffstat (limited to 'code/debug/communication/rx/rx_decode_teensy/src/main.cpp')
| -rw-r--r-- | code/debug/communication/rx/rx_decode_teensy/src/main.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/code/debug/communication/rx/rx_decode_teensy/src/main.cpp b/code/debug/communication/rx/rx_decode_teensy/src/main.cpp new file mode 100644 index 0000000..e0a8b9b --- /dev/null +++ b/code/debug/communication/rx/rx_decode_teensy/src/main.cpp @@ -0,0 +1,48 @@ +#include <Arduino.h> + +int incomingbyte = 0; +bool iswriting = false; +String tlocdat = ""; //temporary location data +String locdat = ""; //location data +int ir1 = -99; +int ir2 = -99; +int ir3 = -99; +int ir4 = -99; +int ir5 = -99; +int ir6 = -99; +int ir7 = -99; +int ir8 = -99; + + +void setup() { + Serial.begin(9600); + Serial3.begin(9600); //19200 +} + +void loop() { + if (Serial3.available() > 0) { + incomingbyte = Serial3.read(); + //Serial.print(char(incomingbyte)); + if (incomingbyte == 's'){ + iswriting = true; + tlocdat = ""; + }else if(incomingbyte == 'e'){ + iswriting = false; + locdat = tlocdat; + }else if(iswriting == true){ + //Serial.print(char(incomingbyte)); + tlocdat += (char)incomingbyte; + } + } + //Serial.println(locdat); + sscanf(locdat.c_str(), "%d, %d, %d, %d, %d, %d, %d, %d", &ir1, &ir2, &ir3, &ir4, &ir5, &ir6, &ir7, &ir8); + Serial.print("IR sensor N: "); + Serial.print(ir1); + Serial.print(ir2); + Serial.print(ir3); + Serial.print(ir4); + Serial.print(ir5); + Serial.print(ir6); + + delay(10); +}
\ No newline at end of file |
