-2

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!

  • what numbers are you talking about? – jsotola Aug 3 '18 at 1:08
  • Serial.list()[2] can easily refer to COM4 as well. – Dmitry Grigoryev Aug 7 '18 at 11:31
3

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.

  • Indeed. The numbers do match. But you are trying to match a number with a name, and those do not match. Or are you Number 6? – Majenko Aug 2 '18 at 21:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.