public void P2() { buttonP0.setColorBackground(gray_); buttonP1.setColorBackground(gray_); buttonP2.setColorBackground(green_); // Open the port you are using at the rate you want: if (portopen == true) { myPort.stop(); } myPort = new Serial(this, Serial.list()[2], 9600); portopen = true; }