very simple serial question

I am trying to send a value to my arduino 1-127 through a serial connection from my computer, and have it save in a variable, does anyone out there already have this code written? The issue I'm having is that it only prints out one number at a time, I'm pretty sure I could figure this out but thought I would ask and see if anyone has already done this.

Thanks

Does this help...

http://arduino.cc/en/Tutorial/SerialCallResponse

  • Brian

I figured it out. Here is the code

byte incomingByte[3];      
int count=0;

void setup() {
  Serial.begin(9600);
  Serial.println("READY");
}
void loop() {
  if (Serial.available() > 0) {
    incomingByte[count]=Serial.read();
    count++;
    if(count==3){
      int total = 0;
      for (int i = 0; i < count; i++){
        total = total*10 + (incomingByte[i] - '0');
      }
      Serial.println(total);
      count=0;
    }
  }
}