From 3d4372df3c0fd76fd78f7ba6dee02f678ffa51f2 Mon Sep 17 00:00:00 2001 From: Abel Tim Date: Sun, 8 Feb 2026 14:09:12 +0100 Subject: i am the only one who reads there anyways so why do i bother imagen there is a butifull commit message here _____________________________________ / Nothing so needs reforming as other \ | people's habits. | | | \ -- Mark Twain / ------------------------------------- \ ^__^ \ (oo)\_______ (__)\ )\/\ ||----w | || || --- .../communication/rx/rx_decode_teensy/src/main.cpp | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 code/debug/communication/rx/rx_decode_teensy/src/main.cpp (limited to 'code/debug/communication/rx/rx_decode_teensy/src') 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..f91d6d3 --- /dev/null +++ b/code/debug/communication/rx/rx_decode_teensy/src/main.cpp @@ -0,0 +1,48 @@ +#include + +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); //split recieved data into seperate variables + Serial.print("IR sensor N: "); + Serial.print(ir1); + Serial.print(ir2); + Serial.print(ir3); + Serial.print(ir4); + Serial.print(ir5); + Serial.print(ir6); + + delayMicroseconds(1); +} -- cgit v1.2.3