Using a Potentiometer and a PCA9685 to control a servo

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Post Reply
User avatar
BiggWigg
 
Posts: 2
Joined: Sun Feb 02, 2025 5:43 pm

Using a Potentiometer and a PCA9685 to control a servo

Post by BiggWigg »

Hi all,

I am having difficulties with creating smooth movement on a servo motor using a potentiometer and a PCA9685 with an Arduino. My goal is to control a servos position, speed, and upper and lower travel limits, using 4 potentiometers, however I cannot seem to get even one operating correctly. I was using the ServoEasing library as opposed to the standard Adafruit PCA library in an effort to achieve smoother movement, however that has now started creating issues with I2C so I am going to return to using the standard library.

Would anyone be able to provide some example code, using the Adafruit PCA library, for smoothly controlling a servo's position using a potentiometer?

Thank you in advance.

EDIT: I should add that another reason for using the ServoEasing library was the ability to control things like the servo's speed and end-stops with simple commands, as I struggled to find any info on doing this with the Adafruit library. Any help with that aspect would also be greatly appreciated.

User avatar
adafruit_support_bill
 
Posts: 89671
Joined: Sat Feb 07, 2009 10:11 am

Re: Using a Potentiometer and a PCA9685 to control a servo

Post by adafruit_support_bill »

that has now started creating issues with I2C
What kind of issues? What processor are you using?
another reason for using the ServoEasing library was the ability to control things like the servo's speed
The problem with typical hobby-grade RC servos is that you can't actually control the speed. The servo control parameters are embedded in the servo - and most are optimized to go as fast as they can. The only way to slow them down is to break the move down into a lot of smaller moves with a slight delay in between.

For the PCA9685, this means lots of commands on the i2c bus. That is how the ServoEasing library works. And it is unlikely that you would be able to do it any more efficiently using our library.

User avatar
BiggWigg
 
Posts: 2
Joined: Sun Feb 02, 2025 5:43 pm

Re: Using a Potentiometer and a PCA9685 to control a servo

Post by BiggWigg »

What kind of issues? What processor are you using?
Turns out the I2C issue was my code. I am using an Arduino Mega 2560.
Any other issues I have now are in relation to the ServoEasing library, not the Adafruit library, so I suppose this could be considered solved.

User avatar
adafruit_support_bill
 
Posts: 89671
Joined: Sat Feb 07, 2009 10:11 am

Re: Using a Potentiometer and a PCA9685 to control a servo

Post by adafruit_support_bill »

Good to hear you solved it. Thanks for the follow-up.

Post Reply
Please be positive and constructive with your questions and comments.

Return to “Arduino”