I ordered some cheap servos from Amazon before I noticed that there seemed to be two different kinds (digital & analog).
Mine are Tower Pro SG90 Analog (http://www.towerpro.com.tw/product/sg90-analog/)
I was trying to get mine to work with an extremely simple sample code (below) using the Arduino Servo library (using digital pin 3) and I was experiencing the jitters.
I read over the solutions at : https://electronics.stackexchange.com/questions/77502/is-there-a-way-to-stop-servos-from-shaking
While reading that I learned that there is also a digital flavor of the servo: http://www.towerpro.com.tw/product/sg90-7/
I'm wondering if that is part of the problem I'm seeing with the servo jittering. I haven't seen this addressed elsewhere.
My questions are:
- Are those servos even different? Maybe that is just a marketing thing??
- Do I need to switch to using an analog pin for the servo data connection?
- Is it even possible to use the Arduino Servo library for this purpose or do I need to use some manual code (like analogWrite()) and move the servo to an analog pin?
- Or, should it work completely fine and the jittering is just some unrelated problem?
Here's the simple code I'm using:
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(3); // attaches the servo on pin 3 to the servo object
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}