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
kiriti:
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!
I experienced a similar problem when I was building project CIRC-04 from the SparkFun Inventor's Kit. The example code provided with the SparkFun Inventor's Guide is very similar to your code sample so I suspect you might be performing the same project.
Although the documentation said the servo supports positions 0 through 180, it seems that positions 1 thru 14 are actually reserved for continuous rotation at different fixed speeds. 1 is fast. 2 is slightly slower. Approaching 14 gets slower and slower.
This means I had to limit my range of motion to positions 15-180. When I adjusted the code to only rotate the server to positions within this range, it worked fine.
If I wanted to watch the servo slowly spin non-stop, I could instruct the servo to seek position 14 and watch it turn slowly. For more excitement, I could instruct the servo to seek position 1 and watch it spin faster. Fun stuff!
I suspect different servos could have different properties. The servo included in my kit was labeled "Micro Servo 9g A0090". If your servo is different, you might try stepping through various target positions to isolate which values provide the continuous rotation feature.
I want to just support the answers listed here already. When the servo is near 0 or 180, there is vibration. I keep the values around 20-150 (which is all that I need) and the servo is perfectly still when holding those positions. Experiment maybe with the kind of servo you have.... mine are Hitec HS-81 micros.
Hi,
You never power servos or motors from the Arduino's 5v, it can't take it! Your servo can use 1A to drive it, but will pull the arduino supply down, causing a brown-out or reset..
So you need a seperate supply for the servo but common the Gnd's, and yes not all servos do 0-180? Power should be a healthy 4 x AA's pref Nimh rechagables.
Get back to us, show us what you have done, etc. Most servo problems are power/connection related.