Hey guys,
I'm trying to parse some serial data coming from the arduino. The arduino is dumping a angle and a distance. An issue im facing is that the arduino is dumping the angle, then a new line, then the distance, then another new line. Its in such a way that the output from putty looks like this:
0 <--angle
12 <---distance
1
45
2
324
.
.
.
180
3
179
14
.
.
.
0
12 and continues until i shut off the arduino
I want to put these data into an an array where dimension 1 is the position and dimension 2 is the distance. Ive read that using a single dim array is much faster due to the poorly optimized multidim array but I'm not sure why. The angle can only go to 180 and back, the distance has a max value of 400cm. This is coming from a ping sensor that is on a 180 degree sweeping servo. I can make the arduino dump the data into one line and parse out the string into two values but I think this might be slower than making it store values in every other line coming from the serial port. From what I know, the serial data will be coming into a byte array as the buffer for the SerialPort.read(buffer,0,1) where buffer is the byte[]. So to sum things up:
1. data must be processed as fast as possible
2. end result is a multi dim or two single arrays or whatever where for each angel value there is a corresponding distance.
3. the angel data will oscillate from 0 to 180 degrees and back but the distance is variable.
After that I want to convert the vectors into x and y components and plot the points on a bitmap where each pixel represents one centimeter. much like radar-where the image gets updated with new visual points every pass.
All im asking for is a way to grab serial data so that every other line is placed into one variable and the rest in another.