Serial sPort = new Serial(this, Serial.list()[portIndex], 57600);
- First plugin your arduino to usb
- type lsusb to see list of attached usb devices
- type dmesg | tail and it show you which serial port your usb device bind to. In my case, it is something like: [3486.xxxxxx] usb 2-2: FTDI USB Serial Device Converter now attached to ttyUSB0
- or, you may also type dmesg | grep tty
- Then you need to figure out the index of this ttyUSB0. Ubuntu reserved ttyS0 to terminal and 1 until 31. normally ttyUSB0 means 32.