I have tried so many different ways to connect these three servos to the PCA9685 board... I just don't know what I am missing my servos just will not run. I get no error messages in my code.
Below is the code I've used:
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(); // Initiates library.
#define SERVOMIN 250 // 1000 microsecond Minimum pulse length count out of 4096.
#define SERVOMAX 500 // 2000 microsecond Maximum pulse length count out of 4096.
int servoNo = 0; // Defines a counter for servos.
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); //Starts serial connection at 9600 baud rate.
pwm.begin(); //Sends PWM signals.
pwm.setPWMFreq(60); // Sends PWM signals.
delay(20);
}
void loop() {
// put your main code here, to run repeatedly:
for (int pulselen = SERVOMIN; pulselen <SERVOMAX; pulselen++) // Drives each servo one at a time first
pwm.setPWM(servoNo, 0, pulselen); //to maximum pulse length then to minimum pulse length.
delay(300);
for (int pulselen = SERVOMAX; pulselen > SERVOMIN; pulselen--)
pwm.setPWM(servoNo, 0, pulselen);
delay(300);
servoNo ++; //Proceeds to next servo.
if (servoNo > 3) servoNo = 0;
}
If you put your sketch between code-tags on this forum, then we can read it. You may also type three backslash single quotes.
```
Your sketch
```
In the Arduino IDE is a auto-format. It is in the menu or press Ctrl+T.
If you do that, and then make it look even better, then the code is easier to read. Put every indent, every comma, every new line at the right place.
You do that for yourself, it helps to spot bugs.
Have you tried a Servo motor without the Adafruit PWM module ?
The Servo library is in the Library Manager of the Arduino IDE
You're telling the PWM board to send the 4096 steps 60 times per second. That's 245760 steps per second or a little over 4 microseconds per step.
A typical servo pulse is 500 to 2500 microseconds long. That would be 125 to 625 steps per pulse. Your 100 to 2200 step limits are way beyond what servos can typically handle.
Try:
#define SERVOMIN 250 // 1000 microsecond Minimum pulse length count out of 4096.
#define SERVOMAX 500 // 2000 microsecond Maximum pulse length count out of 4096.