The Arduino IDE Serial Monitor

Okay, I accidentally programmed a copy of the Serial Monitor in C#....but thats besides the point.

I'm trying to figure out how the arduino reads the input on Serial Monitor program of the Arduino IDE.

for example I have the Arduino bounce back what I input. I put in 'f' and I get 102...'3' i get 51....'4' I get 52 (9600 baud if that matters)

How is it translating the input to numbers? It doesn't seem to be hex to dec.

The reason I'm asking is I'm going to use it to control a servo (so if I can find out how to input to have it spit out 1-180 degrees, I can program that into my c# program).

Thanks!

Here is the code in the chip if that matters:

int val = 0; // variable to store the value coming
             // from the sensor

void setup() {

 Serial.begin(9600); // open the serial port to send
                     // data back to the computer at
                     // 9600 bits per second
}

void loop() {

  
        if (Serial.available() > 0) 
        {
            // read the incoming byte:
            val = Serial.read();
      }

      // say what you got:
      Serial.print(val);
        delay(2000);
}

have a look here... pay attention to the Dec and Chr columns http://www.asciitable.com/

Thanks Jeff K!

int val = 0; // variable to store the value coming // from the sensor

Change to byte, and the rest should work.

save it to your pc :P