Serial.print("Motoren er paa: ");
Serial.print(newPos);
Serial.print(" og forsoeager at ramme ");
Serial.print(sdata);
Serial.print("\n");
delay(1000);
} while(newPos != sdata) ;
}
}
The problem is, when open serial monitor, and what ever you type, it will change the number you entered, then it changes it to 49....
You are assuming that if you type "120" in the Serial Monitor, and press the send button, that the value in sdata will be 120. That is not the case. The string that you typed, "120" is composed of three characters, '1', '2', and '0'. The values in sdata will then be '1', '2', and '0'.
You need to include an end-of-packet marker ("45;", "8;", "129;", for example), then read serial data, as it becomes available, until the end of packet marker arrives. You need to store the data in an array (of characters), keeping the array NULL terminated, then use the atoi() function to convert the string to a number.