I used both a SG90 servo that I tested stand alone on Arduino UNO and know it works a range of 180° (approx) and a DM996 that is new. I use the library suggested by the vendor (NachtRaveVL (NachtRave) · GitHub)/**[PCA9685-Arduino]).
I have tested position 0of16 (DM996) and 1of16 (SG90 ) - the PCA9685 board is connected on I2C with an ARDUINO Nano (4&5 pin) but with a separate battery pack for the servos.
It's a while I'm out of the forum - hope to attach properly the code etc. . Tks. Flavio
#include <Wire.h>
#include "PCA9685.h"
PCA9685 driver;
// PCA9685 outputs = 12-bit = 4096 steps
// 2.5% of 20ms = 0.5ms ; 12.5% of 20ms = 2.5ms
// 2.5% of 4096 = 102 steps; 12.5% of 4096 = 512 steps
PCA9685_ServoEval pwmServo(100, 512); // (-90deg, +90deg)
void setup() {
Wire.begin(); // Wire must be started first
Wire.setClock(400000);// Supported baud rates are 100kHz,400kHz, and 1000kHz
driver.resetDevices();// Software resets all PCA9685 devices on Wire line
driver.init(); // Address pins A5-A0 set to B000000 init(B000000)
driver.setPWMFrequency(50); // Set frequency to 50Hz
}
void loop() {
driver.setChannelPWM(1, pwmServo.pwmForAngle(180));
delay(1000);
driver.setChannelPWM(1, pwmServo.pwmForAngle(0));
delay(1000);
}