Pages: [1]   Go Down
Author Topic: My Servo vibrates rapidly.  (Read 171 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The servo (Futaba S3003) that I am using for my project sometimes vibrates rapidly after it has finished rotating. I have to give it a little push with my finger to get it to stop, which sort of defeats the purpose of the whole project because my project was simply to control a servo remotely using two buttons, one to rotate clockwise 90 degrees, and the other button to rotate 90 degrees anticlockwise.

I thought it may have because both of my if statements are inside the void loop (), so they could be repeatedly running. To fix this I created a variable called limiter, to make sure no same rotation could happen twice in a row.

Is it possible to do what I've done below or am I missing something?

I declared "int limiter = 1;" in void setup ()

Code:

void loop(){
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

if (buttonState == HIGH && limiter == 1) {     
    // rotate clockwise   
    myservo.writeMicroseconds(1800); 
    limiter = 2;
  }

  if (buttonState != HIGH && limiter == 2) {
    // rotate anticlockwise
    myservo.writeMicroseconds(1200);
    limiter = 1;
}
}


I really hope there's a problem somewhere there (there's definitely no problem elsewhere) because I don't want to have to buy a bloody servo again, it takes ages to deliver too.  smiley-mad Cheers  smiley-red
Logged

Oregon, USA
Offline Offline
Edison Member
*
Karma: 69
Posts: 2381
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hopefully you are not attempting to power the servo from the Arduino. If so, don't. Use a separate power supply and connect the  grounds together.
Logged

"It seems to run on some form of electricity"

Lacey, Washington, USA
Offline Offline
Faraday Member
**
Karma: 162
Posts: 2500
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I second what jremington said, plus make sure you are using bypass capacitors on both power supplies.
Logged

Steve Greenfield AE7HD
CET Consumer Electronics and Computer
Please don't read your attitudes into my messages

0
Offline Offline
Tesla Member
***
Karma: 145
Posts: 9686
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
my project was simply to control a servo remotely using two buttons, one to rotate clockwise 90 degrees, and the other button to rotate 90 degrees anticlockwise.

Two button servo code.

Code:
//zoomkat servo button test 12-29-2011
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include <Servo.h>
int button1 = 4; //button pin, connect to ground to move servo
int press1 = 0;
int button2 = 5; //button pin, connect to ground to move servo
int press2 = 0;
Servo servo1;

void setup()
{
  pinMode(button1, INPUT);
  pinMode(button2, INPUT);
  servo1.attach(7);
  digitalWrite(4, HIGH); //enable pullups to make pin high
  digitalWrite(5, HIGH); //enable pullups to make pin high
}

void loop()
{
  press1 = digitalRead(button1);
  if (press1 == LOW)
  {
    servo1.write(170);
  }   
 
  press2 = digitalRead(button2);
  if (press2 == LOW)
  {
    servo1.write(10);
  }
}

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: