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

what's wrong with that code?

enter image description here

Any suggestion would be appreciated

1
  • Please show what research was done and ask a more specific question. Currently the question is too vague. Commented Mar 16, 2021 at 2:11

1 Answer 1

1

Notice the Console output of printArray(Serial.list()).

You have a single serial port "COM4" at index 0.

Any index higher than that (e.g. 32) is out of the valid array index bounds.

The code you're using has a helpful comment:

// if you are a Windows user, please change Serial.list()[your number] 

Simply swap the 32 for a 0 and that should do it.

Try to read and understand the code your using: imagine what the code your reading would do and how it run, then actually run it and compare your assumptions to the actual behaviour. Use the Processing reference where you're not familiar. This will help you a lot as a programmer.

For more details see Processing Serial reference.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.