i would avoid byte things at all,
stick with readable ASCII you can follow in arduino monitor ( terminal )
and easy debug in processing.
ARDUINO
// https://discourse.processing.org/t/unable-to-receive-serial-data-from-arduino/14100
// kll tested also with a arduino leonardo
//Arduino program::
//To send on the serial port a value defined by the
//cursor of a potentiometer
#define POT 0 //assigns input 0 to the potentiometer
int val = 0; //val is the input variable
void setup() {
Serial.begin(9600);//open the serial port and
// set the speed at 9600 bit/sec
}
void loop() {
val = analogRead(POT);//read the voltage on pin A0 and name it val
// Serial.print(val);//transmit val to the serial port
Serial.println(val);//transmit val to the serial port
// delay (10); //wait 10mS ( 100 lines per sec ?)
delay (100); //wait ( 10 lines per sec better start slow )
}
PROCESSING 3.5.3
import processing.serial.*;
Serial myPort;
String data, val="NaN";
int var;
void setup_serial() { // USB arduino..
printArray(Serial.list());
String portName = Serial.list()[1]; // adjust you arduino USB port
myPort = new Serial(this, portName, 9600);
myPort.clear();
myPort.bufferUntil('\n');
println("try connect to "+portName);
}
void serialEvent(Serial p) { // handle serial data
data = trim(p.readStringUntil('\n'));
if (data != null) {
val = data;
var = int(val);
println("val "+val+" var "+var); // print every GOOD line and if it is understood
}
}
void setup() {
size(640, 360);
setup_serial();
}
void draw(){}