Arduino & Proccesing

This might be more of a processing code but I cant get into the web site for some reason.
All right so Im just starting this out and i need for the Arduino chip to send two variables to processing thats all!! For some reason I haven’t been able to do it and it killing me here is my code if someone could tell me what I’m doing wrong !
The string is being read but its storing it only in one variable i need it with two different variables in processing values.
Arduino.

double AccelY, AccelX, RotationZ;
                        
void setup()
{
  Serial.begin(9600);                       
}
void loop()                     
{ 
 RotationZ = analogRead(0); 
 AccelY = analogRead(5);
 AccelX = analogRead(4);
// Serial.println(RotationZ); //Serial.println("Rotation");
 int x = 88;
 int y = 90;
Serial.println(x);

Serial.println(y);

  }

Processing

import processing.serial.*;

int val; // To store data from serial port, used to color background
Serial port; // The serial port object

void setup() {
  size(200,200);
  
  // In case you want to see the list of available ports
  // println(Serial.list());
  
  // Using the first available port (might be different on your computer)
  port = new Serial(this, Serial.list()[0], 9600); 
}

void draw() {
  // The serial data is used to color the background.   
 background(0); 
}

// Called whenever there is something available to read
void serialEvent(Serial port) {
  // Data from the Serial port is read in serialEvent() using the read() function and assigned to the global variable: val
  String Xaccl = port.readStringUntil('\n');
  String Yaccl = port.readStringUntil('\n');
  if (Xaccl != null){
  Xaccl = trim(Xaccl); 
  float XAccl= float(Xaccl);
 
  println(XAccl); 
  } 
  if (Yaccl != null){
  Yaccl = trim(Yaccl); 
  float YAccl= float(Yaccl);
  
 
  //println(YAccl); 
  }
 
}

Whats wrong with this ? both 90 and 88 are being stored in AXccl !

  String Xaccl = port.readStringUntil('\n');
  String Yaccl = port.readStringUntil('\n');

There is a time lag between sending and receiving serial data. You are not allowing any delay, so the second read returns right away, because there is no data to read.

Try changing the Arduino code to Serial.print() the first value, then Serial.print() a ",", then Serial.println() the second value.

Then, learn how to parse the string in Processing.

Alright I know there are infinte posts trying to find out how to get variables from arduino to processing so here is the answer

with a little help from PaulS I figured it out!

This is just a simple example sending some gyroscope readings.

Arduino Code:

int AccelY, AccelX, RotationZ;
                        
void setup()
{
  Serial.begin(9600);                       
}
void loop()                     
{ 
 RotationZ = analogRead(0); 
 AccelY = analogRead(5);
 AccelX = analogRead(4);
 //Serial.println(RotationZ/510);// Serial.println("Rotation");
 Serial.print(AccelY);// Serial.println( "Accel Y");
 Serial.print(' ');
 Serial.println(AccelX);// Serial.println( "Accel X");
delay(2000);
  }

processing code

import processing.serial.*;

int val; // To store data from serial port, used to color background
Serial port; // The serial port object

void setup() {
  size(200,200);
  
  // In case you want to see the list of available ports
  // println(Serial.list());
  
  // Using the first available port (might be different on your computer)
  port = new Serial(this, Serial.list()[0], 9600);
  port.clear(); 
}

void draw() {
  // The serial data is used to color the background.   
 background(0); 
}

// Called whenever there is something available to read
void serialEvent(Serial port) {
  // Data from the Serial port is read in serialEvent() using the read() function and assigned to the global variable: val
  String Xaccl = port.readStringUntil(10);
  //String Yaccl = port.readStringUntil('\n');
  if (Xaccl != null){
   //print(Xaccl);
   float[] Accl = float(split(Xaccl, ' '));
   double Y = Accl[0], X= Accl[1];
   print(Y); print("Y ");
   print(X); println("X");

  //println(XAccl); 
  } 

}