Get -1 from Serial.read

Hello guys, I'm sending two values from MaxMsp to Arduino, but the second it not read and is displayed with -1, why ? Screenshot attached.

How can I send these two int ?

Thanks

Albi

p.s. I'm reading as float into Arduino, but I've tried also with int and gives me -1 anyway.

Yes, in fact I can send n int to numero1, but not to numero2 that is always -1 ......because I need two separate values.....

 int number1;
int number2;

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

}

void loop() {
 
if (Serial.available()) {
 number1=Serial.read();
 number2=Serial.read();
 Serial.println (number1);
 Serial.println (number2);
}

}
Serial.begin (9600);

serial is slower than your mcu

it will detect a char in the serial buffer and process the first before the 2nd arrived.

when you read() and there is nothing in the buffer, it returns -1.

Delta_G:
You check to see if at least one character is available and then read 2. Why not check for 2 available?

if (Serial.available() >= 2) {

number1=Serial.read();
number2=Serial.read();

It works DeltaG!! Thanks a lot for your help!! Thanks also to BulldogLowell :slight_smile: