user26574: I am writing a very simple code in Arduino Nano, in which I am reading data that I send on Serial. Here is the code snippet.
int incomingByte ;   

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

void loop() {


    if (Serial.available() > 0) {

            incomingByte = Serial.read();


            Serial.print("I received: ");
            Serial.println(incomingByte);
    }

}
When I send 'A' , I receive the following output:
I received: 65
I received: 13
I received: 10
What is wrong with the working of Serial Port here?

user36766: this is just because you are typing a letter i  the serial monitor ans in your code your are declaring it as a integer 'int' so you not need to worry about that just try the following code
int incomingByte ;   

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

void loop() {


    if (Serial.available() > 0) {

            incomingByte = Serial.read();
            Serial.write(incomingByte);
    }
}

--------------------------------   OR    ---------------------------------------
char incomingByte ;   

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

void loop() {


    if (Serial.available() > 0) {

            incomingByte = Serial.read();
            Serial.print(incomingByte);
    }
}

Both of the programs will work try that.......

user31105: You send a string "A" 
However, to denote the end, a carriage line (code 13) + line feed (code 10) is sent.
So what is sent is actually an 'A' character followed by a return.
This way you also know when a new line starts
Just strip off the return (13,10) items if you do not need them.
If you do not want to send the return, try sending 'A' (which is the character A, and not the string A.
Update
You can ignore them by:
     if ((incomingByte != 10 && (incomingByte != 13))
     {
        Serial.print("I received: ");
        Serial.println(incomingByte);
     }

If you only want printable characters, check if you can use the isprint function (isprint function
so it should look like
    if (isprint(incomingByte))
    {
        Serial.print("I received: ");
        Serial.println(incomingByte);
    }


user18489: nothing is wrong, it's to do with operator overloading and the print function trying to be helpful.
if you change this line:
int incomingByte ;

to this:
char incomingByte ;

it should display correctly
And the extra characters are because the software on the computer is sending line endings. these may be a linefeed with or without a carriage return. you could either just ignore them, or make use of them to create multi character commands (if you need them)

26574: <p>I am writing a very simple code in Arduino Nano, in which I am reading data that I send on Serial. Here is the code snippet.</p>

<pre><code>int incomingByte ;   

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

void loop() {


    if (Serial.available() &gt; 0) {

            incomingByte = Serial.read();


            Serial.print("I received: ");
            Serial.println(incomingByte);
    }
</code></pre>

<p>}</p>

<p>When I send 'A' , I receive the following output:</p>

<p>I received: 65</p>

<p>I received: 13</p>

<p>I received: 10</p>

<p>What is wrong with the working of Serial Port here?</p>
 36766: <p>this is just because you are typing a letter i  the serial monitor ans in your code your are declaring it as a integer 'int' so you not need to worry about that just try the following code</p>

<pre><code>int incomingByte ;   

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

void loop() {


    if (Serial.available() &gt; 0) {

            incomingByte = Serial.read();
            Serial.write(incomingByte);
    }
}
</code></pre>

<p>--------------------------------   OR    ---------------------------------------</p>

<pre><code>char incomingByte ;   

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

void loop() {


    if (Serial.available() &gt; 0) {

            incomingByte = Serial.read();
            Serial.print(incomingByte);
    }
}
</code></pre>

<p>Both of the programs will work try that.......</p>
 31105: <p>You send a string "A" </p>

<p>However, to denote the end, a carriage line (code 13) + line feed (code 10) is sent.</p>

<p>So what is sent is actually an 'A' character followed by a return.
This way you also know when a new line starts</p>

<p>Just strip off the return (13,10) items if you do not need them.</p>

<p>If you do not want to send the return, try sending 'A' (which is the character A, and not the string A.</p>

<p>Update</p>

<p>You can ignore them by:</p>

<pre><code>     if ((incomingByte != 10 &amp;&amp; (incomingByte != 13))
     {
        Serial.print("I received: ");
        Serial.println(incomingByte);
     }
</code></pre>

<p>If you only want printable characters, check if you can use the isprint function (<a href="http://www.cplusplus.com/reference/cctype/isprint/" rel="nofollow noreferrer">isprint function</a></p>

<p>so it should look like</p>

<pre><code>    if (isprint(incomingByte))
    {
        Serial.print("I received: ");
        Serial.println(incomingByte);
    }
</code></pre>
 18489: <p>nothing is wrong, it's to do with operator overloading and the print function trying to be helpful.</p>

<p>if you change this line:</p>

<pre><code>int incomingByte ;
</code></pre>

<p>to this:</p>

<pre><code>char incomingByte ;
</code></pre>

<p>it should display correctly</p>

<p>And the extra characters are because the software on the computer is sending line endings. these may be a linefeed with or without a carriage return. you could either just ignore them, or make use of them to create multi character commands (if you need them)</p>
