USB Issues with Leonardo boaard

My computer seems to forget what my leonardo board is from time to time. I can be working on a sketch, connecting and disconnecting, testing, etc. Everything going great and then out of the blue, my computer just refuses to recognize the leonardo device, and it no longer shows as being connected in the arduino IDE. Anyone else seen anything like that, and is there an easy workaround to getting windows and leonardo playing nicely again. Reboots don't seem to help either.

And it gets weirder. I have this simple sketch:

int E1 = 5;     //M1 Speed Control
int E2 = 6;     //M2 Speed Control
int M1 = 4;    //M1 Direction Control
int M2 = 7;    //M1 Direction Control

void setup()
  analogWrite (E1,255);
  analogWrite (E2,255);    

void loop()




By the way, this is actually a Romeo board, which is based on Leonardo. Writing a HIGH to pins 4 & 7 is supposed to spin the motor forward, and writing a LOW is supposed to spin the motor backwards. And it does--but ONLY if the USB is plugged in. As soon as I unplug it, something very strange happens. With the sketch above, the motor will pin backward for 1 second, and then it stops for about ten seconds, and then it runs backward for 1 second, pause for ten, etc.

So, usb plugged in, everything runs great. Unplug the usb, and all of a sudden I don't seem to be able to write to those pins. Since this is a robot, I really don't want to have to keep the usb plugged in all the time.

Someone please help! This is my daughter's last week of school and she wants to take the robot into class before school gets out :slight_smile: