Windows 10 getting intermittent errors of not uploading

I’m new to Arduino, i wanted to get a servo working, i was writing this program and it worked fine:

#include <Servo.h>
int pos = 0; // variable to store the servo position
int servoPin= 9;
int servoDelay=25;
Servo myPointer;

void setup()
{
Serial.begin(9600);
myPointer.attach(servoPin); // attaches the servo on pin 9 to the servo object
}

void loop() {

for (pos=15; pos<=170; pos=pos+1) {

myPointer.write(pos);
delay(servoDelay);

}

for (pos=170; pos>=15; pos=pos-1) {

myPointer.write(pos);
delay(servoDelay);
}
}

Then i would change the speed or really anything and i would get an error on the Arduino, the servo kept running the above program.

The error:

Arduino: 1.8.5 (Windows 10), Board: “Arduino/Genuino Uno”

Sketch uses 928 bytes (2%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM3 -b115200 -D -Uflash:w:C:\Users\dukat\AppData\Local\Temp\arduino_build_870122/Blink.ino.hex:i

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch

System wide configuration file is “C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf”

Using Port : COM3
Using Programmer : arduino
Overriding Baud Rate : 115200
avrdude: ser_open(): can’t set com-state for “\.\COM3”

avrdude done. Thank you.

An error occurred while uploading the sketch

This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.

Even at times the Arduino would say it worked but it wouldn’t.

i dont have an external power to the 1 servo…could this be causing a problem ?

Any help would be great ! :)

I saw this a while ago but decided patience was a virtue.

Let me first remark that by 37 posts I would have hoped you would have learned to post code by now.

I will drop by when that is fixed as I have some suggestions.

ballscrewbob: I saw this a while ago but decided patience was a virtue.

Let me first remark that by 37 posts I would have hoped you would have learned to post code by now.

I will drop by when that is fixed as I have some suggestions.

I was not aware there was an alternative way to post code here, i thought that was a clean way, i have never been told otherwise, i'm just here asking for help.

Thanks guys

Then May I suggest some light reading HERE

Also if you have anything connected to the board remove those connections for testing purposes.

This is how i have my board setup

|500x451

I'm thinking the servo is a high torq servo and maybe the board doesn't have enough umf to power it.

That would do it !

Separate PSU for the servo with a common ground back to the Arduino. Then see where you go from there.