Every time I plug in an Arduino Uno on my computer, I need to change the code (Python, pyfirmata library) to connect to a different "COM{n}" port. I would like to be able to have a piece of code that will always be able to connect to an Arduino when it is connected via USB. The piece of code that I use to establish connection to the Arduino is as follows:
self.board = pyfirmata.Arduino("COM4")
The parameter of the function is what always changes if I change Arduino. It could change to "COM7" for example, randomly. Is there a solution to this, so I can always connect to the Arduino, and not have to change the COM port all the time manually?