Urgent! Create a graph vs. time in processing for multiple values?

I am currently using multiple pins (A1-A5) to read the voltage at various points on my circuit. I have them all as an array in a serial string. How would I import this to processing and graph each value vs time on the same graph?

Thank you

I have them all as an array in a serial string.

This doesn't make sense. You either have all the values in an array, OR you have them all in a string.

How would I import this to processing

Serial::readBytesUntil()

and graph each value vs time on the same graph?

Draw 5 lines, from one point to another - line().

I'm sorry. I have them in a serial string and would like to use these values to create 5 separate lines on a graph vs. time. I apologize for being so vague but I'm fairly lost and just looking for a bit of assistance. Thank you in advance if anyone can help me out a bit more as I'm not sure I follow what was said above.

Coincidentally, I just stopped by to pimp a little Processing sketch I wrote for doing (I think) just what you want.

It will plot the serial data you print from your Arduino. The easiest way to get started is print the letter "d", followed by your tab-separated numbers, all on one line. If you have an array of data called "data", and "n" is the number of items in the array, you should be able to do something like this:

Serial.print("d");
for (int i = 0; i < n; i++) {
    Serial.print("\t");
    Serial.print(data[i]);
}
Serial.println();

It will auto-range the plot as data comes in, so it'll look funny at first, but it should get better over time. If you want to get fancier, you can optionally provide names, fixed ranges, and 2d pairings for your data. There's a working example with all the features turned on here: GitHub - dahart/arduplot_lsm9ds0_example: SparkFun's example sketch for lsm9ds0, modified for use with arduplot.

Lemme know if this works or helps!

I'm sorry, I'm new to this and am not really sure what's going on with the example that you provided or how to modify it.

My arduino code is SUPER simple and I just need a very very basic processing graph.

int A,B,D,U,C,T;

void setup()
{
Serial.begin(9600);
}

void loop()
{
A = analogRead(A0);
B = analogRead(A1);
D = analogRead(A2);
U = analogRead(A3);
C = analogRead(A4);
T = analogRead(A5);

Serial.print(A);
Serial.print(",");
Serial.print(B);
Serial.print(",");
Serial.print(D);
Serial.print(",");
Serial.print(U);
Serial.print(",");
Serial.print(C);
Serial.print(",");
Serial.println(T);
}

That is my code. It produces a 6 integer string with each separated by a comma. I need to import it into processing and create a single graph that plots each of these 6 values. They can all be in the same window or in different windows as your example shows but I need to be able to dictate the color of each input. Thank you again for everyone who has helped and I'm sorry that I'm so lost.

No worries, the example is maybe a bit complicated.

Arduplot will plot multiple data like you want. It doesn't have separate colors, but now they're on my todo list. It will display names on each row, if you provide names. I've modified your code so it'll work with Arduplot and display names.

I forgot to mention that by default Arduplot connects to the serial port at a higher baud rate, so that it takes less time to do all the serial communication. You can use any baud you want, you just have to match the baud that your arduino sends with the baud that Processing receives. Notice I changed your Serial.begin().

I haven't run this code, but once it compiles, you should be able to run Arduplot from Processing and see the plot.

Actually one other note, Arduplot will try to connect to the serial port named with the string "tty.usbmodem" in it. This works on my Mac with a USB connection to the Arduino, but I've not tested this on Windows or Linux yet. If it doesn't connect automatically, find the list of serial ports in the Processing output window when you run Arduplot, then change the setup() function in Arduplot to find the serial port you're using - just replace the string "tty.usbmodem" with something that will match your serial port. I'd love to make that part platform independent and automatic, if anyone else here knows how...

int A,B,D,U,C,T;

void setup()
{
  Serial.begin(115200);
  Serial.println("n\tA\tB\tD\tU\tC\tT");
}

void loop()
{
  A = analogRead(A0);
  B = analogRead(A1);
  D = analogRead(A2);
  U = analogRead(A3);
  C = analogRead(A4);
  T = analogRead(A5);

  Serial.print("d\t");
  Serial.print(A);
  Serial.print("\t");
  Serial.print(B);
  Serial.print("\t");
  Serial.print(D);
  Serial.print("\t");
  Serial.print(U);
  Serial.print("\t");
  Serial.print(C);
  Serial.print("\t");
  Serial.println(T);

  delay(20);
}

Any luck, spooky? BTW, did you intend your variables to spell "abduct"?

FWIW, I added colors to arduplot, fixed the serial initialization to be more automatic on a Windows machine, and changed the data delimiting to be any whitespace.

(or if you just want a direct download of the latest file: https://raw.githubusercontent.com/dahart/arduplot/master/arduplot.pde)

The modified code I posted before will still work, but the following will now work too, and is prettier:

void setup()
{
  Serial.begin(115200);
  Serial.println("n A B D U C T");
}

In your loop(), you could replace the Serial.print("\t") with Serial.print(" "). And you can assign colors, in your setup() function like so:

void setup()
{
  Serial.begin(115200);
  Serial.println("n A B D U C T"); // assign names

  Serial.println("c A 255 0 0");   // assign color red     to A
  Serial.println("c B 0 255 0");   // assign color green   to B
  Serial.println("c D 0 0 255");   // assign color blue    to D
  Serial.println("c U 255 255 0"); // assign color yellow  to U
  Serial.println("c C 255 0 255"); // assign color magenta to C
  Serial.println("c T 0 255 255"); // assign color cyan    to T
}