Home > Back-end >  Why printing '10'?
Why printing '10'?

Time:06-30

I wrote a program for char to decimal below, and I don't know why it printing '10' in between.

int variable;

void setup() 
{
    Serial.begin(9600);
}

void loop() 
{
    if(Serial.available() > 0)
    {
        variable = Serial.read();

        Serial.println(variable);
    }

}

CodePudding user response:

10 is \n in ASCII which is println very likely appending to the output in each call.

Use Serial.print to only print the number.

CodePudding user response:

You should specify expected output for better understanding in order to answer

  • Related