Pages: [1]   Go Down
Author Topic: Simple Servo is freaking out  (Read 652 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey,
I'm new to arduinos and have come across a weird problem with a simple micro servo. I'm using the arduino uno. With servo wires Vcc plugged into +5v on arduino, ground on arduino and signal to digital 9. I'm running the following code. When I run the program the arduino immediately moves clockwise and never stops, it keeps pushing and spastically jittering against its limit angle.
The step motor handles angles <= 160degrees

Thanks!

Does anyone know what the problem could be?

Code:
#include <Servo.h>
Servo myservo;
void setup()
{
  myservo.attach(9);
}
void loop() {
myservo.write(20);
delay(1000);
myservo.write(100);
delay(1000);
}
Logged

Johannesburg. UTC+2
Offline Offline
Faraday Member
**
Karma: 82
Posts: 3855
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Spastic Servo Syndrome often happens when the servo is powered from the Arduino which cannot provide enough current.  Give it its own power with ground common-ed to Arduino. That might solve the problem....
Logged

The Elders of the Internet know who I am.....
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

UK
Offline Offline
Tesla Member
***
Karma: 101
Posts: 6320
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

the arduino immediately moves clockwise and never stops,

I doubt that you mean this literally. If you are more precise with your use of language it will be easier to help you.

...R
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

*Never stops trying to move right

Thanks for your replies
Logged

UK
Offline Offline
Tesla Member
***
Karma: 101
Posts: 6320
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

*Never stops trying to move right

I was actually trying to draw your attention to the words "the arduino immediately moves"

I strongly suspect the arduino does NOT move.

...R
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

*Never stops trying to move right

The usual suspects are inadequate power supply, inadequate ground between the servo and arduino, and a corrupt/bad servo control signal.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Pages: [1]   Go Up
Jump to: