i connected it using the arduino power supply
the 5v and the ground pins on the arduino to the servo and the signal to the pin 9
and my code just reads an input from pin 7 and executes it executes sweep once.... and yeah input is working fine ive checked the input readings on serial monitor using println function:)
yeah so powering it i am doing it directly from arduino connected to pc via usb, and when ever i connect the servo the device unmounts itself from windows and device goes into unrecognized and yeah servo works fine with normal sweep but doesnot with my code in which i just pasted the sweep code into the if loop
Always, always use an external power supply for a servo; servos can easily overload the Arduino's voltage reg output, causing power sags and resets, etc. Put an external supply on the servo (and tie the grounds together). If you still run into problems, post your schematic and code, please!