I found this error on Google several times, but it didn't help me much.
I am trying to upload a new program to my recently received Arduino UNO r3, but got this error:
avrdude: ser_open(): can't open device "\\.\COM1": The system cannot find the file specified.
I use the Arduino IDE 1.6.5 on Windows 8.1.
I checked the device manager. The port is still com4 as when I uploaded yesterday.
Also the IDE tools->port shows the same com4.
I tried to change it to com5 via the device manager.
The IDE follows, but the avrdude still insists on using COM1.
I tried to reset the Arduino using the reset button while reconnecting the USB (which also powers it).
But the Arduino resumes running the program from yesterday when I let the reset button go.
The device manager still shows com5. But the avrdude still tries to use the COM1 port.
What do I not understand ?
I found a solution.
In the C:\Users\<user>\AppData\Roaming\Arduino15\preferences.txt file, the parameter serial.port was somehow set to COM1. I changed it to COM5 as expected and it works fine.
I don't know how it got set to COM1 in the first place though.
That's the solution.
thank you very much
it was the only way to fix the problem and I really search for it a lot till I find this great answer.
by the way, to find out the preferences.txt direction (since in different computers it can be any where!) in Arduino IDE go to File --> preferences --> and at the end line of the opened window there is a link in blue which by clicking sent you to the right direction. In there you can change the COM number to what you really want to fix the problem.
good luck :)
I have the same problem too which you seem to have solved. May I just check that I have located the correct file which needs to be amended before I attempt to change things? I have followed your instructions and opened the (blue) link which has taken me to a file the end of which looks like the following:
Please can you tell me if this is correct and that I need to change two sets of COM1 to my required port?
Many thanks R
I noticed even if you make changes to preferences.txt , sketch still try to refer COM1. Also when you restart sketch editor it defaults the preferences.txt back to COM1. In my case port was COM5 on Win10 PC. I just selected Tools-->Port and after expanding Port menu i see three options COM3, COM4 and COM5(Arduino/Genuino UNO), select the port you need, i selected COM5 and then it was showing as selected under Tools Menu and problem was solved . I restarted Sketch and it was referring to COM5 going forward. Hope this helps.
Worked for me, thx!