I was having some problems on a project, so to test my Arduino, I wrote the following program to check things. When I start the serial monitor, the value of i is 1, but after I start sending numbers, they change into ASCII. Why?

int i = 1;
void setup(){
void loop(){
    i = Serial.read();

When you send the character 1, Serial.read() returns the integer 49.
Serial.println(i) then sends the characters 4, 9, carriage return and a newline.

If you want to get back the same characters that you sent, change the type of i to char.

Your Answer

