Pages: [1]   Go Down
Author Topic: Servo vibrates  (Read 2135 times)
0 Members and 1 Guest are viewing this topic.
Hyderabad, India.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 98
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hey guys i connected the servo and everything works fine including the sweep

but when i use this code to read input from switch and then sweep servo it vibrates

Code:
#include <Servo.h>
int switchpin=7; //Input From button
Servo myservo;
int pos=1;
int value;
void setup()
{
  pinMode(switchpin, INPUT);
  myservo.attach(9);
  Serial.begin(9600);
}
void loop()
{
  value=digitalRead(switchpin);
  Serial.println(value);
  if(value==1)
  {
    for(pos = 1; pos < 45; pos += 1)
  {                                 
    myservo.write(pos);             
    delay(35);                     
  }
  for(pos = 45; pos>1; pos-=1) 
  {                               
    myservo.write(pos);           
    delay(1);                       
  }
  }
}

is it because of coding error or the signal wire being lose??
Logged

Hyderabad, India.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 98
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i dont understand it, it acts wiered sometimes it works sometimes it doesnot, it vibrates sometimes smiley-sad
Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8905
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You probably need to explain how your servo is connected to the arduino, how you are powering the servo, and just what your code is supposed to do.
Logged

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

Hyderabad, India.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 98
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Logged

Phoenix, Arizona USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 5519
Where's the beer?
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

Offline Offline
Newbie
*
Karma: 1
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Kiriti,

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.

Hope this helps,
-John
Logged

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

i've just started messing around with servos

as far as i can see, driving the servo beyond its physical limits will cause the vibrating

i discovered when using the sweep programme that i needed to make the limits between 30 and 170 degrees before the servo would stop chattering

Logged

Pages: [1]   Go Up
Jump to: