0

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:

  1. receive compiled code from a PC (from Arduino IDE: Sketch > Upload)
  2. 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.

1

1 Answer 1

3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.