Serial is not reading expected values

Hi

I am fairly inexperienced with Arduino. My project is a musical instrument based around an Arduino. People will touch a graphite strip connected to the Arduino with a spoon, generating analogue values to play as notes.

My problem is that when inputting values into the serial monitor, the first number that displays is the first digit of the input plus 48. The second number that displays is the second digit of the input plus 48.

For example, if I type 4, I get:

I received: 52.

If I type 795, I get:

I received: 55 I received: 57 I received: 51

What I want to happen is for the number displayed to be the same as the number inputted.

This is my code:

int incomingByte = 0;   // for incoming serial data

void setup() {
        Serial.begin(9600); // opens serial port, sets data rate to 9600 bps 
        int tonePin = 9;
        
}

void loop() {

        // send data only when you receive data:
        if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();
                // say what you got:
                Serial.print("I received: ");
                Serial.println(incomingByte);
                
        }
}

Thank you in advance for your response.

If I type 795, I get:

I received: 55 I received: 57 I received: 51

What you are seeing are the ASCII values for the 3 separate digits that you entered.

Have a look at Serial input basics

Serial.println(incomingByte);

This line means: print the value of incomingByte (which is an int) in a decimal representation.
And the name is not very clever. incomingByte should be a byte, or have a different name.

Try this version that outputs the received byte in different ways

char incomingChar;   // for incoming serial data

void setup() {
  Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
  Serial.println("Enter some text please");
}

void loop() {

  // send data only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingChar = Serial.read();
    // say what you got:
    Serial.print("I received: '");
    Serial.print(incomingChar); // print char
    Serial.print("' value ");
    Serial.print((int)incomingChar, 10); // in decimal
    Serial.print(" 0x");
    if (incomingChar < 16) {
      Serial.write('0');
    }
    Serial.print((int)incomingChar, 16); // in hex
    Serial.print(" 0b");
    Serial.println((int)incomingChar, 2); // in binary
  }
}
Enter some text please
I received: 'I' value 73 0x49 0b1001001
I received: ' ' value 32 0x20 0b100000
I received: 'l' value 108 0x6C 0b1101100
I received: 'i' value 105 0x69 0b1101001
I received: 'k' value 107 0x6B 0b1101011
I received: 'e' value 101 0x65 0b1100101
I received: ' ' value 32 0x20 0b100000
I received: 'C' value 67 0x43 0b1000011
I received: '+' value 43 0x2B 0b101011
I received: '+' value 43 0x2B 0b101011
I received: '
' value 13 0x0D 0b1101