using 2 servo to dwar circle

Hi I found this post: and

I have successfully used it by modifying it for PCA9685, but when the servos are moving they make noise (like a "grrrr") is there a solution to solve this problem?
same problem using the pin on the arduino nano like the link (using servo.write)

Thank you
best regards

Please post the wiring diagram and the code the way told in the topic "How to use this Forum".

Often, a servo that just makes noise has the signal (yellow or white) wire connect to an Arduino pin but the Ground (black) wire is not connected to the Arduino Ground.

Or maybe you just need better servos. Can't tell much because you have provided no information about what Arduino or servos or code or power or wiring you're using.


thanks at all
the scheme is the adafruit pca9685 connected to arduino nano with SCL, SDA, +5v and GND and the servos ar connected to PCA with 5V separate voltage (but common GND :wink: )
this is the code

i have tried both micro servo and standard servo

thanks again

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm0 = Adafruit_PWMServoDriver(0x40);

#define SERVOMIN  205 // This is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX  410 // This is the 'maximum' pulse length count (out of 4096)
#define SERVO_FREQ 50 // Analog servos run at ~50 Hz updates

int servoX_circle= 0;
int servoY_circle= 1;

void setup() {
  pwm0.setPWMFreq(SERVO_FREQ);  // Analog servos run at ~50 Hz updates

void loop() {
for(int i=0; i<=360; i+=5){
      int x = 40 * (cos ((3.14 * i)/180)) + 90;
      int y = 40 * (sin ((3.14 * i)/180)) + 90;

      int Pos_servoX_circle= map(x, 0, 180, SERVOMIN, SERVOMAX);
      pwm0.setPWM(servoX_circle, 0, Pos_servoX_circle);

      int Pos_servoY_circle= map(y, 0, 180, SERVOMIN, SERVOMAX);
      pwm0.setPWM(servoY_circle, 0, Pos_servoY_circle);



As asked for previously, a circuit diagram.
Show what your power supplies are.

sorry, I thought it was enough to describe it.
I have a separate power supply with 5V 2A power supply for the PCA which then supplies power to the servos.
I hope the photo below goes well (i use the arduino nano using SDA SCL correct pin)

i have try to use servo normally (go to 90°, pause, go to 180°, pause, etc. and the noise not appear)


So you're taking PCA board power from the Nano. How is the Nano powered?

Why did you need to change the default oscillator frequency to 27MHz? Any improvement if you take that line out?

I'm wondering if you're changing the PWM too often. What happens if you temporarily change the delay to say 50 or even 100?


  1. no, as I said above I have 2 separate power supplies: one for PCA (5V 2A) and one for arduino nano 5v 1A
  2. about 27Mhz i dont know. i have used the setting found on adafruit site. I don't think it works without it, but tonight I can try.
  3. I also tried at 10, 20, 50, 100, 200 and 1000ms, but (for ex. in 1000ms) for many positions it makes noise and in others it doesn't! :frowning:

the weird thing is that if I use it without passing values FOR cycle, it works fine with no noise
in my opinion there are values that, when passed close to each other, are make noise

thanks again

maybe I discovered the error
is it possible that the values go reversed?

pwm0.setPWM(servoX_circle, 0, Pos_servoX_circle);


pwm0.setPWM(servoX_circle, Pos_servoX_circle, 0);

setPWM(channel, on, off)
This function sets the start (on) and end (off) of the high segment of the PWM pulse on a specific channel. You specify the 'tick' value between 0..4095 when the signal will turn on, and when it will turn off. Channel indicates which of the 16 PWM outputs should be updated with the new values.

  • channel: The channel that should be updated with the new values (0..15)
  • on: The tick (between 0..4095) when the signal should transition from low to high
  • off:the tick (between 0..4095) when the signal should transition from high to low

That doesn't make much sense to me. Why would it go low at 0, before it has gone high Pos_servoX_circle ticks after 0? But then I'm not that good at PCA9685s nor do I understand how your values are supposed to work. What does it do when you try it?


just tried to remove the line pwm0.setOscillatorFrequency (27000000);
and nothing changes without -> so it is useless -> I have removed definitively. thanks
I tried to swap the values by putting (Pos_servoX_circle, 0) but it doesn't work right. I thought that being the first value the saita front and the second value the falling down would go inverted. but I was wrong! :frowning:
now I don't know what to do :frowning:


I can't imagine why an inverse pulse would work better but if you want to try it then it should probably be

pwm0.setPWM(servoX_circle, Pos_servoX_circle, 4095);



Perhaps this comment in the servo.ino example is important:

   * In theory the internal oscillator (clock) is 25MHz but it really isn't
   * that precise. You can 'calibrate' this by tweaking this number until
   * you get the PWM update frequency you're expecting!
   * The int.osc. for the PCA9685 chip is a range between about 23-27MHz and
   * is used for calculating things like writeMicroseconds()
   * Analog servos run at ~50 Hz updates, It is important to use an
   * oscilloscope in setting the int.osc frequency for the I2C PCA9685 chip.
   * 1) Attach the oscilloscope to one of the PWM signal pins and ground on
   *    the I2C PCA9685 chip you are setting the value for.
   * 2) Adjust setOscillatorFrequency() until the PWM update frequency is the
   *    expected value (50Hz for most ESCs)
   * Setting the value here is specific to each individual I2C PCA9685 chip and
   * affects the calculations for the PWM update frequency. 
   * Failure to correctly set the int.osc value will cause unexpected PWM results

in fact it could be due to inaccurate frequencies.
in fact I tried to send the values with 2000ms delay and I read them from the terminal. not all of them produce noise, but only some (e.g. 322 makes noise but 325 does not)

i have to see if you can adjust as in the comments of the servo.ino code
I have an old oscilloscope in the basement, I need to see if it still works!

I recorded the audio of the servo, to make it clear what I'm talking about.
I specify that I have modified the code so as to make the servo go step by step with the above code, but when it arrives at the bottom it returns directly to the beginning.
As you can hear it grates when it goes slowly step by step, but it makes no noise when it quickly returns to the starting position (this noise is the classic servo sound)

the link is:

thanks again
best regards

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.