How to control servos with potentiometer while using a Adafruit PCA9685

Hi everyone, beginner here so i don't know a lot but I think I know the simple code to control servos with a potentiometer with only an arduino uno and a breadboard, but I am confused when it comes to the pca9685.

I think normally to control servo I have to put in include <Servo.h>, but to use the pca9685 I see videos where people don't include that at all but instead, put include <Wire.h> and include <Adafruit_PWNServoDriver.h> such as this video: 16 channel servo controller with Arduino | PCA9685 16 channel PWM servo motor driver tutorial - YouTube

I think there's also some difference between
code without pca9685: Arduino Tutorial: Servo Potentiometer Control - Beginner Project - YouTube

code with: 16 channel servo controller with Arduino | PCA9685 16 channel PWM servo motor driver tutorial - YouTube

So is there a way to control servos with pot while using the adafruit servo library? If so, can I use the same code as the DroneHow vid? Also what is wire.h?

Is there a reason why you are using the PCA9685 to control the servos rather than connecting the servos directly to the Arduino ?

Normally, it is spelled "PWM", not "PWN"

Normally spelled "Wire.h", it specifies the I2C drivers.

Because I have to control 4 servos or is it possible to connect 4 servos directly to the Arduino?

Oh i see, does the Pwnservodriver.h replace servo.h?

Yes, as long as they are powered by an external power supply as they should be when used with the PCA9685 in any case

The Servo library supports up to 12 motors on most Arduino boards and 48 on the Arduino Mega.

But how tho, all the vids on yt I see when they r controlling multiple servos they r using some thing like pca9685 or a breadboard.

By connecting servos directly to the arduino do you mean soldering or is there other way to connect servos to the arduino uno without breadboard or soldering?

Perhaps they're all sponsored by manufacturers of PCA9685 boards. (sp. "are")

If you've got an Uno, you can simply poke patch wires into the servo connector and into the pin

A PCA9685 and a breadboard are completely different things. One is a passive device and the other an active device. As AWOL has pointed out you can easily connect servos to a Uno using jumper wires. However, you must use an external power supply for the servos as the Uno cannot supply enough current, but you were going to do that anyway, weren't you ?

Perhaps to clarify this a bit.

There are two options for operating four (or more, or less) servos.

One is to use software - a servo library - to cause the UNO to laboriously generate all the pulses required for the servos. This means the code is very "busy" and it may or may not be practical to do various other things at the same time - the code to drive the servos may interact with other tasks and vice versa.

The PCA9685 is a hardware device with 16 channels available to generate servo control pulses - or PWM (which is not the same as servo pulses) quite independently of the Arduino. You issue commands to it via the I²C interface - which means you have to use the "Wire.h" library which implements I²C - and you use a different library to instruct the PCA9685 to specifically generate the servo pulses.

Each time you issue a servo command to the PCA9685, it automatically continues to send the servo control pulses for that position with no action from the Arduino until you wish to command a different position. You are not using the servo library to cause the Arduino to generate the pulses.

1 Like

OHHHHHHH I see, so you meant that I can connect the 4 servos signal and ground wires directly to the arduino signal and ground pins and the 5v wires of the servos connect to the external supply?

Yes, that is what I mean

Sry but i still don't understand how to do this. If i connect my external power supply to the 5v and gnd pin of the arduino, where do i connect the 5v wire of the servos as theres only 1 5v pin in the Arduino uno

To the external power supply.

You have previously answered your own question

sry for bad drawing but what i was saying is, theres no more slots to connect with the power supply since its only 2 wires is already connect to arduino uno board.

Suffice to say, you use "connectors".

And the servo grounds do not connect directly to the Arduino. :roll_eyes:

They connect to the power supply in the same way as the servo positive wires.


like this?

Bit more like it.

If you do have a power supply with a coaxial connector on it, you want one of these:

You probably could get five servo wires (plus the Arduino power wires) into each of the screw openings.

Also, you need to run the control wires alongside the other wires, you do not want to have them separate as this allows pickup of interference which may upset the operation of your whole system.