Upload fails: 'avrdude: ser_open(): can't set com-state for "\.\COM3"'

my sketch is correct but theres an error when uploading:
avrdude: ser_open(): can't set com-state for "\.\COM3"
here is my sketch incase something went bad/wrong:
#include <Servo.h>

Servo myservo;

int pos = 0;

void setup() {
myservo.attach(9);
}

void loop() {
for (pos = 0; pos <= 180; pos += 1) {
myservo.write(pos);
delay(15);
}

}

Ah, yes, that's not an issue with your code. That's an issue with the arduino board. Make sure that you have selected the correct board type in the arduino IDE, as well as the correct COM port. If you don't know the COM port, make sure the arduino is plugged in and just randomly try them until you get one that works

ok so my com port is com3 and I selected the right board but I don't see an arduino uno r3 so I chose the arduino uno

That should be correct....

R3 means revision 3. It doesn't really change anything, so that's fine. It's the COM port causing issues.

OK, so if there aren't any other COM ports (Or they are showing something like "Could not find board on COM port XXX"), then check to see if you have any other software communicating to the arduino. Unity3D can communicate to it if you are using the "System.IO.Ports package". Python can communicate using the "Serial" package. Other software might be interfeering with it. If you don't have any other software running that could stop the arduino from being communicated with, try either starting the arduino IDE with administrator priveledges (Right click icon and go "Start as administrator"), or try disabling your antivirus. Sometimes antivirus might trip and stop you from uploading sketches. Personally I've never had that happen, but it's worth a shot

Hi,
What OS are you using?
What version of the IDE are you using?

Do you have any hardware connected to pins 0 and 1 of the UNO?
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile: