Date from Arduino in Processing

Hi guys,
I want to sent my data ( PPG-ECG wavs) from Arduino uno in Processing and then plot it
I tried to write a code for it. that partially worked and now I want to extend it. So instead of plotting the data as points, I want normal signals to plot

can someone help me with this!

`import processing.serial.*;

// import the Processing serial library
import processing.serial.*;
import java.io.BufferedWriter;
import java.io.FileWriter;
Serial myPort; // The serial port

// Test values
int v1 =0;
int v2 = 255;
int x;
int NumOfScopes,NumOfInput=2;
void setup() {
size(640,480);
// Open serial port
//printArray(Serial.list());
myPort = new Serial(this, Serial.list()[0], 115200);

// Read bytes into a buffer until you get a linefeed (ASCII 10):
myPort.bufferUntil(’\n’);

//draw with smooth edges:
//smooth();
background(255);

}

void draw() {

// Draw circles
fill(204, 102, 0);
ellipse(x, v1, 5, 5);
fill(#00ff00);
ellipse(x, v2, 5, 5);

// Update x position
x++;

// Refresh screen
if (x > 600) {
background(255);
x = 0;
}
}

// serialEvent method is run automatically by the Processing applet
// whenever the buffer reaches the byte value set in the bufferUntil()
// method in the setup():
void serialEvent(Serial myPort) {

// read the serial buffer:
String myString = myPort.readStringUntil(’\n’);
println(“raw: \t” + myString);
// if you got any bytes other than the linefeed:
myString = trim(myString);

// split the string at the commas
// and convert the sections into integers:
int values[] = int(split(myString, ‘,’));

if (values.length >= 2) {
v1 = values[0];
v2 = values[1];
printArray(v1);
println(v2);
}
}`

Hello! This looks like it will indeed plot two sets of numbers. But what is a “normal signal”?

Hi, thank you for the answer. I mean wanna to see the signal exactly as in arduino Ide and not as a point. I am sending you the results in Arduino ide and in Processing


Uploading: processing.JPG…

Oh you mean a proper graph with scales and everything. Use the grafica library. It looks like what they’re using in the Arduino IDE.

1 Like

yes, thats exactly what I meant. I’ve already overridden the library. Unfortunately I still can’t get any signal. Do you have any examples?

You’ve done what to the library?

Not sure why it isn’t showing up. There are a lot of examples with grafica. I seem to remember needing to call plot.setPoints(yourGPointsArray); again to update the graph.