Arduino Sketch suddenly too big

I’m programming a servo with a metal claw attached using a modified version of the “sweep” example servo code. It worked perfectly yesterday and was under the maximum amount of bytes. Today, however, all my sketches exceed 2,048 bytes, including the example codes for Servos. I get the error code “avrdude: ser_open(): can’t set com-state” every time. Is this an issue with my arduino size? Any comments are appreciated!

Sweep.2 (Modified Sweep Example Code):

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop() {

myservo.write(20); // tell servo to go to position in variable ‘pos’
delay(1000);
myservo.write(160); // tell servo to go to position in variable ‘pos’
delay(1000);
}

As it is so small please post the code here rather than attaching it.

I get the error code “avrdude: ser_open(): can’t set com-state”

Is that the only error message that you get ?

(deleted)

That seemed to do the trick! Thank you for helping me out!

Cannot set com state generally means the USB serial adapter is in a bad state - this can happen due to a power glitch on the Arduino (from you shorting it out, or from trying to run a large and/or inductive load off the USB power), if you unplug and replug it while something is using it, or similar situations. Unplugging and replugging the arduino usually sorts it out, and if it doesn't, plugging it into a different port almost always will (or you can just reboot)