String inString = ""; void setup() { Serial.swap(1);// to use alternative Rx/Tx, because I connected the wrong ones on my board Serial.begin(9600); // opens serial port, sets data rate to 9600 bps } void loop() { //for location10, 11 and 12, which are more than 1 byte while (Serial.available()>0) { int inChar = Serial.read(); if (isDigit(inChar)) { // convert the incoming byte to a char and add it to the string: inString += (char)inChar; } // if you get a newline, print the string, then the string's value: if (inChar == '\n') { //Serial.print("Value:"); int location = inString.toInt(); //Serial.println(location); //Serial.print("String: "); //Serial.println(inString); // clear the string for new input: inString = "";// Serial.print("location: "); Serial.println(location); } } }