Hello
New to Forum and to Arduino and not sure where I should be posting the issue I'm having.
Just pulled out my Arduino UNO, never used it before, and initially all seems okay. I ran the Blink and ASCIITable examples without any problems.
I tried hooking up a micro servo.
Black - ground
Red - 5 volts
Yellow - signal pin 9
When I hooked up the power, (red, black) wires, the 'L' LED flashed, not sure if that's normal, and lastly connected the signal wire - nothing else flashed and I assumed all was good.
Then when I upload the code, and the 'L' LED flashes repeatedly as my computer drops the USB connection to the Arduino. Windows then reconnects the USB comm port and it all starts over.
The USB connection continues to disconnect and reconnect until I pull out any of the servo wires. Once they are out, the USB connection becomes stable once again.
It's hard to believe that this would have anything to do with the code as I'd think that USB connection is rather isolated from program execution, but then this is all new to me.
The code is just for testing, doesn't do much, it was the first example I found on the net.
#include <Servo.h>
Servo myservo; // create servo object to control a servo
void setup()
{
myservo.attach(9); // attaches the servo on pin 9 to the servo object
Serial.begin(9600); //begins serial communication
}
void loop()
{
int pos;
if (Serial.available()){
delay(100);
while(Serial.available()>0){
pos=Serial.read(); //reads the value sent from Visual Basic
if(pos=='0')
myservo.write(90); //rotates the servo 90 degrees (Left)
else if(pos=='1')
myservo.write(-90); //rotates the servo 90 degrees (right)
else if(pos=='2')
myservo.write(180); //rotates the servo 180 degrees (Left)
else if(pos=='3')
myservo.write(-180); //rotates the servo 180 degrees (right)
}
}
}
Any help as to why the USB connection drops when hooking up the servo would be appreciated.
Thanks.