Taking a number in via serial

Hey all,

I'm trying to input a number between 0-255 via serial into arduino and have it register the number.

while (Serial.available() > 0) {
  delay(5); //wait until all the data is received
  int inByte = (Serial.read() - '0'); //subtract 48 from number. Totally not how I want to do this.
  Serial.println(inByte, DEC);
}

I'm having a difficult time, though, trying to get it to take more than one digit at a time (i.e. 12 inputs 1, then 2 in 2 separate commands).

Also, it is not accepting the number as its number value, but instead of its ascii character table relationship number (i.e. 1 is 49, so when i input 1, it takes it as 49).

Thanks as always for any responses.

I'm trying to input a number between 0-255 via serial into arduino

Using? Is the data being sent as a byte or as a string?

while (Serial.available() > 0) {
  delay(5); //wait until all the data is received
  int inByte = (Serial.read() - '0'); //subtract 48 from number. Totally not how I want to do this.
  Serial.println(inByte, DEC);
}

If there is serial data available, the delay is unnecessary.

If the data is being sent as a string:

char inData[4];
byte index = 0;

void loop()
{
   while(Serial.available() > 0 && index < 4)
   {
      inData[index] = Serial.read();
      index++;
      inData[index] = '\0';
   }

   if(index > 0)
   {
      int inVal = atoi(inData);
      // Use inVal...

        index = 0;
        inData[index] = '\0';
   }
}