Am trying to control a MG995 servo with attached sketch. The sketch is first running in a loop from 0 to 180 degrees and then in another loop from 180 to 0.
I notice how the servo moves in the right direction but every now and then it is kind of stepping backwards before continuing.
Is there someone who knows if one have to make some precausions to avoid ripple on the pwm pin if that is
sketch_jan16a.ino (536 Bytes)
the case? I've connected the server control pin directly to pin 9(my servo pin).
Post your sketch in code tags to see how we can help.
Here is my sketch
#include <Servo.h>
Servo Servo1;
int servoPin = 9;
int potPin = A0;
int n;
void setup() {
Servo1.attach(servoPin);
}
void loop() {
n = 0;
while (n <= 180)
{
Servo1.write(n);
n = n + 1;
delay(100);
}
while (n >= 0)
{
Servo1.write(n);
n = n - 1;
delay(100);
}
}
Could you explain more clearly what is the problem with servo?
The code has an error and I don't know if it can alter the operation of the servo.
What is the value of n when entering the second while()?
And what is the maximum value allowed by servo.write()? (at least according to the Arduino reference)
R: 181; 180
A jerky servo could be power supply related, so how are you powering the servo.
That servo has AFAIK a stall current of 1.2Amp.
Leo..
Problem solved. Tried to drive the server straight from Arduino. NOT GOOD.
Added a power supply, work not good a 5V, increased to 7V, ALL GOOD.
Thanks for your help!!!
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.