PCA9685 Button Press

Hey, everyone!

Looking to use the PCA9685 to sweep a series of 10 servos, one after the other, from one degree position to another, slight delay, then back again on a single button push.

All the examples and test code I've found are WAY too involved, and I'm not sure where to start.

Any help you've got laying around would be extremely appreciated. I'm building my nephews a target-shooting gallery! :slight_smile:

Cheers,
Jordan G.

For PCA9685 servo motor driver, you can see the example and library from Adafruit

For push button, you can see this tutorial

IoT_hobbyist:
For PCA9685 servo motor driver, you can see the example and library from Adafruit

For push button, you can see this tutorial

I appreciate the reply. I've already seen the examples (as I mentioned), but they're too complex and involved for what I'm trying to do.

The button is something I'm familiar with, but again, I don't know how to integrate it with the PCA9685.

If you can help guide me in how to combine these two, I'd appreciate it immensely.

Okay, new wrinkle; I figured out 99% of the code, and it works great.

The ONLY thing I don't know is how to trigger the servos to do their thing, one time, on a button press. Right now, they just loop.

Here's my code:

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

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

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

// our servo # counter
uint8_t servonum = 0;

void setup() {
Serial.begin(9600);
Serial.println("10 channel servo test!");

pwm.begin();

pwm.setPWMFreq(60); // Analog servos run at ~60 Hz updates

delay(10);
}

void loop() {
//set (servo to be used, nothing, angle)

pwm.setPWM(0, 0, 150);
delay(500);
pwm.setPWM(0, 0, 200);
delay(500);
pwm.setPWM(1, 0, 150);
delay(500);
pwm.setPWM(1, 0, 200);
delay(500);

}