user-1: A beginner in Arduino programming here (learning Arduino programming while waiting for my board to arrive).
I am trying to understand how Arduino board is able do these two things using only one USB port it has:

receive compiled code from a PC (from Arduino IDE: Sketch > Upload)
serial communication between a PC application and the Arduino board (e.g. our own Windows application communicates with the Arduino board)

I just cannot wrap my mind around how does it distinguish between these two cases. I have used boards which have 2 USB ports: one is for programming (uploading your code) and the other one is for serial communication between any PC application and the board.
In my opinion there has to be some way for Arduino to detect when is it being flashed, and when is it being used as a regular serial port.

user4143: It doesn't distinguish anything. It's all down to what code is running on the board at any moment.
When you reset or power up the bootloader runs. It listens for uploaded code. If it doesn't get an upload signal from the pc after a short timeout it starts executing your code instead.

-1: <p>A beginner in Arduino programming here (learning Arduino programming while waiting for my board to arrive).</p>
<p>I am trying to understand how Arduino board is able do these two things using only one USB port it has:</p>
<ol>
<li>receive compiled code from a PC (from Arduino IDE: Sketch &gt; Upload)</li>
<li>serial communication between a PC application and the Arduino board (e.g. our own Windows application communicates with the Arduino board)</li>
</ol>
<p>I just cannot wrap my mind around how does it distinguish between these two cases. I have used boards which have 2 USB ports: one is for programming (uploading your code) and the other one is for serial communication between any PC application and the board.</p>
<p>In my opinion there has to be some way for Arduino to detect when is it being flashed, and when is it being used as a regular serial port.</p>
 4143: <p>It doesn't distinguish anything. It's all down to what code is running on the board at any moment.</p>
<p>When you reset or power up the bootloader runs. It listens for uploaded code. If it doesn't get an upload signal from the pc after a short timeout it starts executing your code instead.</p>
