Tools > Port gives puzzling result

Why do I get three identical entries for COM6 displayed here please?

(I'm also trying to discover why my program gives an upload error, but if necessary I'll post separately about that.)

Terry

Does the problem still occur if you close all Arduino IDE windows and then start the IDE again?

pert:
Does the problem still occur if you close all Arduino IDE windows and then start the IDE again?

No, thanks a bunch, that fixed it - I should have tried that first!

Terry

I reported the issue of the duplicate ports as part of another bug report here:

the the fix for the primary bug I reported there did not fix the cosmetic issue of the multiple ports. However, I find the multiple ports issue doesn't occur when using the beta build of the Arduino IDE, so I suppose the bug is considered fixed, even though there hasn't been a production release that contains that fix yet.

At the time I reported that bug, the duplicate ports were associated with an upload failure. However, that issue should have been fixed already in the Arduino IDE 1.8.12 version you're using, so I'm not sure whether your upload failure is the same issue I was having (which I don't have anymore when using 1.8.12).

Thanks for those further details. Here, it seems to be directly related to using the Serial Monitor. At the moment I see no fewer than five entries for Com 6 while working with the program below. Perhaps I’m using the monitor wrongly, although I can’t pin it down. For example, opening it again, or removing and replacing the USB cable, has not increased that number to six. I’ll try to remember to check it more frequently to see if I can spot when the number gets incremented.

Meanwhile I’m ignoring it as it doesn’t seem to affect running of the sketch.

/* Blink an LED either 2 or 4 times depending on a switch at D4
  Choice is made in setup mode by setting the variable num.
  That value is then used in loop mode.
  A function blinkNum is used to blink the LED on D8
*/

//PROBLEMS FIXED
// Error message:
// Variable or field 'blinkNum' declared void
// Fixed by reply from groundFungus 14 June 2020
// As well as my careless failure to use PULL-UP on D4

const int ledPin = 8;
const int timeOn = 500;
const int timeOff = 500;
const int switchPin = 4;
int num;


void setup()
{
  Serial.begin(9600);
  Serial.println("Program now in setup");
  Serial.print("num = ");
  Serial.println(num);
  pinMode(ledPin, OUTPUT);
  pinMode(switchPin, INPUT_PULLUP);

  if (digitalRead(switchPin) == HIGH)
  {
    num = 4;
  }
  else
  {
    num = 2;
  }
  Serial.print("num = ");
  Serial.println(num);
  Serial.print("switchPin = ");
  Serial.println(digitalRead(switchPin));
}

void blinkNum(int num)
{
  for (int i = 0; i < num ; i++)
  {
    digitalWrite(ledPin, HIGH);
    delay(timeOn);
    digitalWrite(ledPin, LOW);
    delay(timeOff);
  }

}

void loop()
{
  Serial.print("num = ");
  Serial.println(num);
  blinkNum(num);
  delay(2000);

}

I don't see anything suspicious in your code.

My experiences with this phenomenon were restricted to the native USB boards like the Leonardo, but I have seen some other reports of it happening with the Uno. I don't remember if I actually tested with the Uno. I tend to use my Nano, but the situation is a bit different with the Nano because it has a different sort of USB interface than the one on your Uno, which has the ATmega16U2 with specialized Arduino firmware.

When I reported the bug, I was more concerned with the upload failure than the cosmetic issue of the multiple ports, however this does cause some confusion. If you like, you can try the beta build of the Arduino IDE to see if it still occurs with that version:

I don't really recommend you use the beta build as you everyday IDE, since it's intended to be used for beta testing, and is more likely to have bugs than the standard release versions of the Arduino IDE.