We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f0f9a07 commit bb7c39aCopy full SHA for bb7c39a
Adafruit_PWMServoDriver.cpp
@@ -167,7 +167,14 @@ void Adafruit_PWMServoDriver::setPWMFreq(float freq) {
167
Serial.println(prescale);
168
#endif
169
170
- setPrescale(prescale);
+ uint8_t oldmode = read8(PCA9685_MODE1);
171
+ uint8_t newmode = (oldmode & ~MODE1_RESTART) | MODE1_SLEEP; // sleep
172
+ write8(PCA9685_MODE1, newmode); // go to sleep
173
+ write8(PCA9685_PRESCALE, prescale); // set the prescaler
174
+ write8(PCA9685_MODE1, oldmode);
175
+ delay(5);
176
+ // This sets the MODE1 register to turn on auto increment.
177
+ write8(PCA9685_MODE1, oldmode | MODE1_RESTART | MODE1_AI);
178
179
#ifdef ENABLE_DEBUG_OUTPUT
180
Serial.print("Mode now 0x");
0 commit comments