user48472: I have a Processing program that reads data sent to the serial port by an Arduino. When I go to device manager it shows that the Arduino is plugged into COM 4, however in order to get Processing to read the data the number I need for the COM in the following line is 2: 
String portName = Serial.list()[2]

Why do the numbers not match?
Thanks!

user20533: If you print out portName it should be COM4 it seems you must have 3 COM ports on your machine otherwise you would use index 0; Serial.List() appears to return an array or list which you are taking the third item located at index 2.

48472: <p>I have a Processing program that reads data sent to the serial port by an Arduino. When I go to device manager it shows that the Arduino is plugged into COM 4, however in order to get Processing to read the data the number I need for the COM in the following line is 2: </p>

<pre><code>String portName = Serial.list()[2]
</code></pre>

<p>Why do the numbers not match?</p>

<p>Thanks!</p>
 20533: <p>If you print out portName it should be <strong>COM4</strong> it seems you must have 3 COM ports on your machine otherwise you would use index 0; Serial.List() appears to return an array or list which you are taking the third item located at index 2.</p>
