# Serial port error with ARDUINO

**URL:** <https://discourse.processing.org/t/serial-port-error-with-arduino/871>\
**Category:** Libraries\
**Created:** [June 11, 2018, 2:26pm UTC](https://discourse.processing.org/t/serial-port-error-with-arduino/871 "2018-06-11T14:26:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![F6EEQ](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@F6EEQ](https://discourse.processing.org/u/F6EEQ)\
**Post date:** [June 11, 2018, 2:26pm UTC](https://discourse.processing.org/t/serial-port-error-with-arduino/871/1 "2018-06-11T14:26:39Z")

</div>

First hello to all, I’m brand new to this community!  
So forgive me if my questions are basic.  
I tried to find answer with a search, but did not find.

As a first attempt, I wish to link an ARDUINO and Processing, using the code found in Sparkfun.  
Here is my setup (of course serial library and all other variable have been initialized):  
**myPort = new Serial(this, Serial.list()[9], 9600);**

I checked in the Reference, and this is how a port should be initialized.

And here, the error I get:  
**ArrayIndexOutof BoundsException: 9**

As far as I understand, the port#9 is not recognized, although it is used by my MEGA.  
I tried to input other serial ports numbers, but all ports above 6 (that means 7 and further) are rejected, although they are valid, as I use them for other application.

Is there a limitation on port numbers?? If this is the case, I found no mention in Library docs.

Thanks for your help.

Gerard.

---

<div class="post-metadata">

**Author:** ![GarethWilkins](https://avatars.discourse-cdn.com/v4/letter/g/bbe5ce/32.png) [@GarethWilkins](https://discourse.processing.org/u/GarethWilkins)\
**Post date:** [June 11, 2018, 2:39pm UTC](https://discourse.processing.org/t/serial-port-error-with-arduino/871/2 "2018-06-11T14:39:11Z")

</div>

Look what port the arduino connects to from the settings in the arduino IDE and write this instead of Serial.list()[9]

eg “COM1” or “/dev/tty”

keep the " "

this works for me

---

<div class="post-metadata">

**Author:** ![rogeralms](https://avatars.discourse-cdn.com/v4/letter/r/779978/32.png) [@rogeralms](https://discourse.processing.org/u/rogeralms)\
**Post date:** [June 11, 2018, 3:42pm UTC](https://discourse.processing.org/t/serial-port-error-with-arduino/871/3 "2018-06-11T15:42:29Z")

</div>

Hi, I am also new to this forum. I did this same exercise over the weekend. My Arduino was on COM3 on my computer. I used [0] to connect. If you use debug and look at the Serial.list()[0] then Serial.list()[1] etc. Then use prntln to print these values you can find the correct port. I am still learning this but hope this advice helps.

---

<div class="post-metadata">

**Author:** ![F6EEQ](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@F6EEQ](https://discourse.processing.org/u/F6EEQ)\
**Post date:** [June 11, 2018, 3:43pm UTC](https://discourse.processing.org/t/serial-port-error-with-arduino/871/4 "2018-06-11T15:43:44Z")

</div>

Thanks a lot, it works.

From time ti time it sends a “null” instead of the Welcome, but this is probably a timing problem which I should solve quickly.

Have a nice day.  
Gerard.

---

<div class="post-metadata">

**Author:** ![F6EEQ](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@F6EEQ](https://discourse.processing.org/u/F6EEQ)\
**Post date:** [June 11, 2018, 3:45pm UTC](https://discourse.processing.org/t/serial-port-error-with-arduino/871/5 "2018-06-11T15:45:43Z")

</div>

Hi Roger,

I was sure port is #9, so former advice solved the problem.  
Thanks anyway for jumping in.

---

<div class="post-metadata">

**Author:** ![kfrajer](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kfrajer/32/196_2.png) [@kfrajer](https://discourse.processing.org/u/kfrajer)\
**Post date:** [June 12, 2018, 2:02am UTC](https://discourse.processing.org/t/serial-port-error-with-arduino/871/6 "2018-06-12T02:02:09Z")

</div>

Did you solve your problem? First thing I will do before I open any port is to print the list of ports P3 sees:

`println(Serial.list());`

A neat trick is to run this code before you connect your arduino and then run it a second time after your arduino is connected. You wil be able to see what port your arduino is using.

Kf

---

<div class="post-metadata">

**Author:** ![F6EEQ](https://avatars.discourse-cdn.com/v4/letter/f/e47774/32.png) [@F6EEQ](https://discourse.processing.org/u/F6EEQ)\
**Post date:** [June 13, 2018, 1:17pm UTC](https://discourse.processing.org/t/serial-port-error-with-arduino/871/7 "2018-06-13T13:17:54Z")

</div>

OK, but anyway, you have to upload the ARDUINO program in the board, so you know the used port, as you have to configure it with Arduino tools in the IDE…,
