Skip to main content
Inlined links, added missing '}', fixed code indentation, added code formatting and other minor fixes.
Source Link
Greenonline
  • 3.1k
  • 7
  • 34
  • 48

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

I have edited your serial event method a little bit, so it could handle the data from the arduino, splitted 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 arduino 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 draw method of processing, but I think that this is not the problem. (for the 3d draw you should have a look on the reference of prcessing (https://processing.org/reference/) or at this special topic https://processing.org/tutorials/p3d/ )

I have not tested the code, but I think that it should work.

If you have questions, feel free to ask ;D

I have edited your serialEvent() method a little bit, so it could handle the data from the Arduino, when 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 Arduino 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 draw() method of processing, but I think that this is not the problem.

For the 3d draw you should have a look on the Processing reference or at this special topic, 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

added 1 character in body
Source Link

I have edited your serial event method a little bit, so it could handle the data from the arduino, splitted 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 arduino 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 draw method of processing, but I think that this is not the problem. (for the 3d draw you should have a look on the reference of prcessing (https://processing.org/reference/) or at this special topic https://processing.org/tutorials/p3d/ )

I have not tested the code, but I think that it should work If.

If you have questions, feel free to ask ;D

I have edited your serial event method a little bit, so it could handle the data from the arduino, splitted 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 arduino 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 draw method of processing, but I think that this is not the problem. (for the 3d draw you should have a look on the reference of prcessing (https://processing.org/reference/) or at this special topic https://processing.org/tutorials/p3d/ )

I have not tested the code, but I think that it should work If you have questions, feel free to ask ;D

I have edited your serial event method a little bit, so it could handle the data from the arduino, splitted 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 arduino 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 draw method of processing, but I think that this is not the problem. (for the 3d draw you should have a look on the reference of prcessing (https://processing.org/reference/) or at this special topic https://processing.org/tutorials/p3d/ )

I have not tested the code, but I think that it should work.

If you have questions, feel free to ask ;D

Source Link

I have edited your serial event method a little bit, so it could handle the data from the arduino, splitted 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 arduino 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 draw method of processing, but I think that this is not the problem. (for the 3d draw you should have a look on the reference of prcessing (https://processing.org/reference/) or at this special topic https://processing.org/tutorials/p3d/ )

I have not tested the code, but I think that it should work If you have questions, feel free to ask ;D