Go Down

Topic: Problems with processing 3 -please read (Read 464 times) previous topic - next topic

leonskennedy365

Hello everyone I have problems with a proessing code I'm trying to write a sketch to measure the heartbeat and make a graph on processing.
gives me problems with this processing sketch:


import processing.serial.*;
Serial myPort;
int xPos = 1;
float oldHeartrateHeight = 0;

void setup () {
// set the window size:
size(1000, 400);
frameRate(30);

// List available serial ports.
println(Serial.list());

// Setup which serial port to use.
// This line might change for different computers.
myPort = new Serial(this, Serial.list()[0], 9600);

// set inital background:
background(0);
}

void draw () {
}

void serialEvent (Serial myPort) {
// read the string from the serial port.
String inString = myPort.readStringUntil('\n');

if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int
println(inString);
int currentHeartrate = int(inString);

// draw the Heartrate BPM Graph.
float heartrateHeight = map(currentHeartrate, 0, 1023, 0, height);
stroke(0,255,0);
line(xPos - 1, height - oldHeartrateHeight, xPos, height - heartrateHeight);
oldHeartrateHeight = heartrateHeight;
// at the edge of the screen, go back to the beginning:
if (xPos >= width) {
xPos = 0;
background(0);
} else {
// increment the horizontal position:
xPos++;
}
}
}

the error is given to me in line 12 or println (Serial.list ());
could someone help me?
it does not even show me the graph,I 'm new on processing and I do not know how to move

groundFungus

This is an Arduino forum.  You will get better help from the Processing forum.  

You will need to post the error message in its entirety if you expect help. 

leonskennedy365

They removed the registration from the forum

groundFungus

I use Processing , some.  If you post the message I will see if I can help.

leonskennedy365

The error says
Type String of the last argument to method println(Object...) doesen't exactly match the vararg parameter type. Cast Object to confirm the non-varargs invocation,or pass individual arguments of type Object for a varags invocations.
in line 12
 
Thanks

groundFungus

Your code compiles fine with my Processing ver 3.3.6.  I, then, did a search for your error and found this thread which may help.

leonskennedy365

Now I don't have any error bu the graphic doesen't work; When i run the sketch it opens the graphic wndow but I see a black screen.

groundFungus

I don't know if it is appropriate to continue this, Processing, discussion in the Arduino Sensors forum.  I suggest that we use PM.

Go Up