I have edited your serial eventserialEvent()
method a little bit, so it could handle the data from the arduinoArduino, splittedwhen split by a tab.
void serialEvent (Serial myPort) {
String inString = myPort.readStringUntil('\n');
if (inString != null) {
values=split(inString,"\t"); //Splitting the output of the arduino into a String Array
for(int i=0;i<values.length;i++){
values[i]=trim(values[i]); //deleting the whitespaces as before
float_values[i]=float(values[i]); //cast the string to a float as before
}
x = map(float_values[0], 0, 1023, 0, height); //map the value as before
y = map(float_values[1], 0, 1023, 0, height);//map the value as before
z = map(float_values[2], 0, 1023, 0, height);//map the value as before
newVal = true;
}
}
so your sending on the arduinoArduino has to look like this:
void loop()
{
x = ski.getXRaw();
y = ski.getYRaw();
z = ski.getZRaw();
Serial.print("\n");
Serial.print(x);
Serial.print("\t");
Serial.print(y);
Serial.print("\t");
Serial.print(z);
delay(10); //(make it readable)
}
You still have to make the drawing in the drawdraw()
method of processing, but I think that this is not the problem.
(for
For the 3d draw you should have a look on the reference of prcessing (https://processing.org/reference/Processing reference) or at this special topic, https://processing.org/tutorials/p3d/P3D by Daniel Shiffman ).
I have not tested the code, but I think that it should work.
If you have questions, feel free to ask ;D