COM Port Error: Port Not Found

actually, another addition you need is a check if you’ve already initialised the com-device (Arduino).
you can do this by changing

if (device_detected) {
    text("Device detected:", 20, 110);
    textFont(fnt, 18);
    text(detected_port, 20, 150);
  }

to

if (device_detected && ser_port /*(or MySerial)*/ == null) {
    text("Device detected:", 20, 110);
    textFont(fnt, 18);
    text(detected_port, 20, 150);
    Ser_port /*or MySerial*/= new Serial(this,detected_port,9600);
  }