Hi, new to the forum here, sorry if I format wrong or posted in the wrong place.
I'm trying to get an Arduino UNO to send speed and wheel rotation count to another Arduino Mega in the form:
<speed,rotationCount,>
I can successfully send and receive it, but when I try to output the parsed data to the serial monitor from the Mega, it seems to be repeating one of the variables at the end of the line, and I can't figure out why it would be doing that.
What I am expecting is:
07:21:30.157 -> Data: 15,472, counter: 472 speed: 15
07:21:30.157 -> Data: 15,473, counter: 473 speed: 15
07:21:30.157 -> Data: 15,474, counter: 474 speed: 15
but what I actually get is:
07:21:30.157 -> Data: 15,472, counter: 472 speed: 15472
07:21:30.157 -> Data: 15,473, counter: 473 speed: 15473
07:21:30.157 -> Data: 15,474, counter: 474 speed: 15474
If I comment out the Serial.print(receivedChars) line, I get:
07:22:10.878 -> Data: counter: 479 speed: 16479
07:22:10.878 -> Data: counter: 480 speed: 16480
07:22:10.878 -> Data: counter: 481 speed: 16481
When I comment out the Serial.print(rotationCounter) line, I get:
07:24:18.405 -> Data: 16,487, counter: speed: 1616,487,
07:24:18.405 -> Data: 16,488, counter: speed: 1616,488,
07:24:18.405 -> Data: 16,489, counter: speed: 1616,489,
And if I comment out both, I get:
08:04:59.356 -> Data: counter: speed: 16)
08:04:59.529 -> Data: counter: speed: 16⸮
08:04:59.704 -> Data: counter: speed: 16{
08:04:59.878 -> Data: counter: speed: 16$
08:05:00.017 -> Data: counter: speed: 16⸮
08:05:00.225 -> Data: counter: speed: 16v
08:05:00.395 -> Data: counter: speed: 16#
My knowledge of C++ and serial communication isn't much, so I'm hoping someone here can help me understand whats going on.
receivingSerialData_Test.ino (2.81 KB)