Hello everyone, i am using switch/case instance that reads a char from matlab via serial read (eventually used to control a demux from matlab) and a while loop that uses serial read again to control data to read from an array of sensors, then send the data back to matlab.
I have everything setup, where my switch/case statements uses Serial.available > 0, and my while loop uses Serial.available == 0. The problem i am having is with the while loop, i am successful in getting to the while loops. attempting to read data from a for loop in matlab for 16 sensors, results in the first and second data to show NaN from arduino, but the remainding values from the sensors are read correctly.
Can anyone help understand why the first two reads are not working as intended? I think it has something to do with the serial buffer not being handled correctly up until the 3rd attempt. Any help would be greatly appreciated.
Figured it out please close thread mods, thank you.