Weird numbers in the Serial monitor

When i use the Serial.read() and Serial.println functions, after typing 1, it prints 49, when i type 2, it prints 50, etc.

Moderator edit: removed superfluous offensive language.

Google "ASCII table" and see if it makes more sense after looking at one of those.

Thanks a lot! I didn't know that. I figured out that I could make the values good using the map() function...

If they're just digits 1 - 9 there's a sneaky trick.

int someValue = Serial.read() - '0';

Look again at the ASCII table and you'll see how it works. (HINT: writing '0' with single quotes is the exact same thing as writing 48)

Thanks! I'll also try that...

I have another issue: How do I group numbers in the Serial monitor. Because a number with several digits, like 42, is considered 4 and 2. How could i group it?

What do you mean by grouping it? You mean reading it into a variable? Read in the first digit and put it in your variable. Now you var equals 4. Read the second digit. Multiply your variable by ten and add the new digit. So your var becomes 40 + 2 or 42.

That's what i planned to do, but what do you mean by ''reading it'', is there a function that finds the 2-last numbers, or do i have to type the first number, add it in the var, and repeat w/ a second number?

There are a number of ways to enter a number via the Serial monitor. I think this one's pretty simple:

char buffer[10];

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  int charsRead;
  int val;

  while (Serial.available() ) {
    charsRead = Serial.readBytesUntil('\n', buffer, sizeof(buffer) - 1);
    buffer[charsRead] = '\0';
    val = atoi(buffer);
    Serial.print("The number is: ");
    Serial.println(val);
  }
}

The code continues to read the incoming characters until the user presses the Enter key (i.e., the newline character, '\n' is read). It will only read a maximum number of characters equal to the size of buffer minus 1 so there's room for the string termination character ('\0'). Since the readBytesUntil() method returns the number of characters read, that's where the null goes. The call to atoi() (ASCII to Int) converts the digit characters to an integer value and then they are displayed.

Thanks this is really helpful. I'll try that. I definitely need to study the Arduino functions and the ASCII more in depth...