Reading Serial from arduino

I know about Serial.println(). But because i just want to read integer values, it seems Serial.write() should suffice. But the problem is whenever i try to read from serial port and turn my potentiometer that is connected to my arduino board, the change in value gets picked up very late. I think i understand why that happens. But i just need to know how to sync up supercollider with how fast new data arrives in the serial buffer, i think? This is my arduino code.

void setup() {
  Serial.begin(9600);
}

void loop() {
  //only sending one byte per 10 millisecond
  byte val = map(analogRead(A0), 0, 1023, 0, 255);
  int bytesAvailable = Serial.availableForWrite();  //checking if there is space on the buffer
  if(bytesAvailable > 0){
    Serial.write(val);
  }
  delay(10);  
}

Here is my supercollider code

(
p = SerialPort(
    "COM4",
	baudrate: 9600)
)

(
fork {
    loop {
        p.read.postln;
        0.01.wait;
    }
}
)


SerialPort.closeAll; 

So i assume every 10 milliseconds the arduino puts a new byte onto the serial buffer. And i also assum that p.read reads the next byte in the buffer, also every 10 milliseconds. But still when i turn the potentiometer it responds super late.
So my question is, how do i sync up my arduino and supercollider to get the best responsiveness? Maybe i should use something else than serial? I basically just want my knob to change parameter values in supercollider, so that i can control supercollider as a synth for playing live.

I think the delay could be caused by using read with a delay, quoting from SerialPort | SuperCollider 3.14.1 Help

Read a byte from the device. Blocking read.

Since you are sending with around 100 Hz, read will wait for the next message and then also wait for 0.01 seconds, making it effectively (less than) 50 Hz - so messages probably pile up over time since you are not reading fast enough which explains the delay.
So probably remove the 0.01.wait (this may “freeze” the language though?) or use .next which is non blocking, so there you would have to use wait.

Have you tried the example that is given in the docs @ https://docs.supercollider.online/Classes/SerialPort.html#Arduino%20read%20example?

Only a guess, but maybe worth a try :wink:

I always just take the code from this tutorial video from the goat eli fieldsteel and havent had a problem with things feeling unresponsive. Maybe his setup also works for your project!

Thank you for the suggestions and info people. Due to limited time i opted for using MIDI instead of using serial. That saved me some time in formatting and debugging and in general results in cleaner code. Im using digital rotary encoders, so i dont really need to be able to send continuous values from arduino to supercollider.