The PCA9685 driver for Servos is used to modulate the pulse width of a channel on a PWM extender connected to the Builder Base. This driver provides the 50 Hz signal for servos with a variable duty cycle.
The PCA9685 driver for servos has two parameters that need to be configured:
This is the address the device is being referenced by on the I2C bus. The base I2C address is
The last 6 bits are altered by the address A0-A5 pins:
A5 A4 A3 A2 A1 A0
1 0 0 0 0 0 0
So as an example if we set all pins to 1 we have
The device has a “can all“ address, which is 0x70, so the I2C scan is going to report two addresses usually: the one selected with the A pins and 0x70.
More information about addressing can be found in the datasheet
Also for translation help see the Binary to Hex converter here
This is the channel on the PCA9685 modulating the pulse width; enter a number between 0-15 to select the channel you want to modulate.
The PCA9685 can be found in either a DIP socket adapter or in popular development boards as shown below
Channel 0 is connected to a Servo directly. The chip is connected to address 0x40 of the I2C bus because none of the connectable addresses is set to HIGH.
If you want to use the male headers on the PCA breakout board to supply power, ground and the PWM signal to the servo and not only the PWM signal, you have to also supply 5V to the V+ pin of the breakout board, because the VCC pin only supplies power to the IC and not to the breakout pins.
The voltage level for the assembly
The ground potential for the assembly
The I2C data line
The I2C clock line
How to write an App
Navigate to the App Builder and create a new application. You can find the “Servo” code object under the “Hardware” Tab in the object drop down menu on the left, or you can also use the search bar.
Drag the “Servo” Object onto the canvas.
Next, locate the “Input Number” Object under the Interface tab and drag three instances of it onto the canvas.
Finally, connect the “Number” port from one of each of the Input Number Objects to the “Degrees”, “Offsets”, and “180 Offsets” ports on the Servo Object and save your application.
How to create a firmware
Navigate to the Firmware Builder and create a new firmware file.
Click the “+ Add Hardware” button which will open a modal window. Scroll down in the list to find the “Generic” section and select the “Servo” hardware option.
Give your device a name, and click “Add Device”
Next, select the “PCA9685” under the driver dropdown menu, set the I2C Address, and the Channel.
For this example we select:
I2C Address: 0x40
You may now save your firmware file and upload it to one of your clients.