Serial Communication Troubles

I created a program with processing witch uses data collected via Arduino's sensors. The problem is that I want my processing program to automatically detect the serial port witch Arduino is connected to.

myPort = new Serial(this, Serial.list()[0], 9600);

With this line of code I need each time to substitute the value (zero) with the correct one witch indicates the right serial port. Is there a way so that it would be automatic and it will work with different computers?

Thanks in advance.

Is there a way so that it would be automatic and it will work with different computers?

That is probably a processing/computer issue and not much to do with an arduino.

The problem is that I want my processing program to automatically detect the serial port witch Arduino is connected to.

How? The Processing app must send something, and Arduino must respond appropriately.

With this line of code I need each time to substitute the value (zero) with the correct one witch indicates the right serial port.

The list() method returned a list of values. You, therefore, know how many times to iterate.

Is there a way so that it would be automatic and it will work with different computers?

If it was easy, don't you think Processing would just do it?

Mad98:
Is there a way so that it would be automatic and it will work with different computers?

I don't know Processing, but I don't think that is possible.

You could write code in such a way that the user can click a button to identify the port to use. That way you don't have to modify the code. See, for example, this Python GUI demo.

...R

Mad98:
I created a program with processing witch uses data collected via Arduino's sensors. The problem is that I want my processing program to automatically detect the serial port witch Arduino is connected to.

myPort = new Serial(this, Serial.list()[0], 9600);

With this line of code I need each time to substitute the value (zero) with the correct one witch indicates the right serial port. Is there a way so that it would be automatic and it will work with different computers?

Thanks in advance.

Uno or Due ?

Vaclav:
Uno or Due ?

I have no experience of the Due.

Does it behave differently from an Uno, Mega or Leonardo ?

...R

I used the Arduino Mega so it's the same as the Arduino Uno

Vaclav:
Uno or Due ?

Because SAM /Due has several USARTs with limited RS232 /EIA controls.
That would be my preference for robust serial communication.

Vaclav:
Because SAM /Due has several USARTs with limited RS232 /EIA controls.

I don't think that has anything to do with the OP's question.

...R

Robin2:
I don't think that has anything to do with the OP's question.

...R

...so why don't YOU let him decide

...so why don't YOU let him decide

Because we've already decided that you are clueless.

What the Processing app needs to do has nothing to do with the kind of Arduino on the other end of the serial port.