Conditioning the sketch on finding the COM port trouble

I’m not sure in your case but some drivers create a virtual com port so maybe that’s what it is trying to open. If you connect an arduino, does it appear as COM27 or show up as another port?

A potential “fix” can be to use try/catch and see if you can actually open the port

import processing.serial.*;

void setup() {
  size(1900, 950, JAVA2D);
  printArray(Serial.list());

  try {
    Serial myPort = new Serial(this, "COM27", 115200);
    myPort.clear();
  } catch (Exception e) { 
    e.printStackTrace();
    delay (3000);
    exit();
  }
}

ps could you add all the imports and variable declarations when you post something like this, so we can run the sketch without editing? :slight_smile:

1 Like