COM port problem

I can't use serial print because whenever I plug in my arduino 2-4 identical COM ports appear and all are selected. How can I fix this?

It seems to be a common problem with one of the IDE versions. Not sure if it's 1.8.10. You can do a search.

I think that the solution is to go back to another version; I'm still on 1.8.5.

Which Arduino are you using ?

I am using 1.8.10 and when using a Nano 33 IOT it sometimes appears to cause a duplicate COM port to appear but it still works OK. I have put the appearance of the second port down to a quirk of the fact that the board switches COM port to a different one when uploading code then changes back to the original once uploading is complete.

I’ve also had the duplicate Tools > Port menu entries issue, and found that the same event that causes the duplicate Port menu entries also caused spurious upload failures in Arduino IDE 1.8.9, as I reported here:
https://github.com/arduino/Arduino/issues/8851

My finding was that the spurious upload error was fixed in Arduino IDE 1.8.10. The duplicate Tools > Port menu entries still occur with Arduino IDE 1.8.10, but I have never experienced any loss of functionality when this happens.

I never had a problem with Serial Monitor associated with the duplicate Port menu entries, even with Arduino IDE 1.8.9.

Which version of the Arduino IDE are you using @AdamAly?

AdamAly:
I can’t use serial print

That’s pretty vague. Please provide a detailed description of the issue you are having.

I am using Arduino 1.8.10 and my problem is that nothing ever shows up on the serial monitor. I simulate this button response time code on TinkerCAD and it shows up but when I actually do it with a real Arduino using Arduino IDE. I assume this problem is because of the multiple COM ports. but if it's not could anybody tell what it is?

this is the code, but I'm pretty sure it's not the problem because it works when I simulate it

int LEDpin=13;
int buttonpin=2;
unsigned long LEDontime;
unsigned long buttontime;

void setup()
{
  Serial.begin(9600);
  pinMode(LEDpin, OUTPUT);
  pinMode(buttonpin, INPUT);
}

void loop()
{
  delay(5000);
  digitalWrite(LEDpin, HIGH);
  LEDontime = millis();
    while (digitalRead(buttonpin) == HIGH) {
    }
    buttontime = millis();
    Serial.print("Reaction time: ");
    Serial.println(buttontime - LEDontime);
  digitalWrite(LEDpin, LOW);
}

Your sketch adds the extra complexity of the button. We don't know whether the problem is with the serial communication or how you have your button wired.

Is the LED behaving as you expect?

Try this minimal test sketch as a sanity check:

void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println("hello");
  delay(1000);
}

Make sure the baud rate menu at the bottom right corner of the Serial Monitor is set to "9600".

Do you still see nothing on the Serial Monitor with that sketch running on your Arduino?

Which Arduino board are you using?