Arduino sends "OK\r" to PC.
PC responses with "1,255,2,90,".
Then Arduino parses first integer from serial buffer.
This integer goes to switch function.
From there, appropiant method is called witch parses next available integer from buffer to be used for motor speed or servo control.
Iv updated my loop code to this:
void loop() {
Serial.println("OK"); //Signal PC software that I am redy!
while (Serial.available() > 0) { //send data only when you receive data:
data = Serial.parseInt(); //read the incoming integer:
WhatToDo(data); //start appropiant function
}
}
The remaining part of the code is unchanged. Arduino is still getting strange numbers.