# Help using PCA9685 to control LEDs

**URL:** <https://forum.arduino.cc/t/help-using-pca9685-to-control-leds/856621>\
**Category:** General Guidance\
**Created:** [May 2, 2021, 5:15pm UTC](https://forum.arduino.cc/t/help-using-pca9685-to-control-leds/856621 "2021-05-02T17:15:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![cratefx](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@cratefx](https://forum.arduino.cc/u/cratefx)\
**Post date:** [May 2, 2021, 5:15pm UTC](https://forum.arduino.cc/t/help-using-pca9685-to-control-leds/856621/1 "2021-05-02T17:15:17Z")

</div>

I am using the PCA9685 to control 6 RGB leds, i have 5 of them connected to the PCA9685 and one connected directly to the arduino pwm pins, my problem is how do i use the setPWM(channel, on, off) command in the library of that chip as it looks nothing like the AnalogWrite command, the setPWM has 2 values one for off and one for on and they range between 0 and 4096 while the arduino pwm pins range between 0 and 255 and they only take in one value per pin not 2.

How do i make them equivalent using variables in the code?  
Thanks.

---

<div class="post-metadata">

**Author:** ![blh64](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/blh64/32/605986_2.png) [@blh64](https://forum.arduino.cc/u/blh64)\
**Post date:** [May 2, 2021, 5:35pm UTC](https://forum.arduino.cc/t/help-using-pca9685-to-control-leds/856621/2 "2021-05-02T17:35:45Z")

</div>

which library are you using? The one in the library reference just specifies the duty cycle, not on and off time.

Either way, this chip deals with 0-4096 which is just your analogWrite() value [0--255] times 4.

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [May 2, 2021, 5:44pm UTC](https://forum.arduino.cc/t/help-using-pca9685-to-control-leds/856621/3 "2021-05-02T17:44:25Z")

</div>

Post a link to that LED connected directly to the controller I/O. It might be a bad idea.

---

<div class="post-metadata">

**Author:** ![cratefx](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@cratefx](https://forum.arduino.cc/u/cratefx)\
**Post date:** [May 4, 2021, 7:56pm UTC](https://forum.arduino.cc/t/help-using-pca9685-to-control-leds/856621/4 "2021-05-04T19:56:06Z")

</div>

I’m using the library by adafruit

---

<div class="post-metadata">

**Author:** ![cratefx](https://avatars.discourse-cdn.com/v4/letter/c/7ba0ec/32.png) [@cratefx](https://forum.arduino.cc/u/cratefx)\
**Post date:** [May 4, 2021, 7:56pm UTC](https://forum.arduino.cc/t/help-using-pca9685-to-control-leds/856621/5 "2021-05-04T19:56:32Z")

</div>

I have a bunch of resistors between the chip and the leds

---

<div class="post-metadata">

**Author:** ![Railroader](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/railroader/32/274550_2.png) [@Railroader](https://forum.arduino.cc/u/Railroader)\
**Post date:** [May 4, 2021, 8:13pm UTC](https://forum.arduino.cc/t/help-using-pca9685-to-control-leds/856621/6 "2021-05-04T20:13:10Z")

</div>

You give no useful information, no code, no wiring so I give You no help.

---

<div class="post-metadata">

**Author:** ![gilshultz](https://avatars.discourse-cdn.com/v4/letter/g/67e7ee/32.png) [@gilshultz](https://forum.arduino.cc/u/gilshultz)\
**Post date:** [May 5, 2021, 1:10am UTC](https://forum.arduino.cc/t/help-using-pca9685-to-control-leds/856621/7 "2021-05-05T01:10:39Z")

</div>

I agree and no links to the parts!

---

<div class="post-metadata">

**Author:** ![Wawa](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/wawa/32/1211303_2.png) [@Wawa](https://forum.arduino.cc/u/Wawa)\
**Post date:** [May 5, 2021, 1:48am UTC](https://forum.arduino.cc/t/help-using-pca9685-to-control-leds/856621/8 "2021-05-05T01:48:05Z")

</div>

Are these LEDs common \<=20mA indicator LEDs ?

Why did you choose the PCA9685.  
Wouldn't it be easier to use addressable LEDs.

Please tell us more about your project.  
Leo..

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 2, 2021, 1:48am UTC](https://forum.arduino.cc/t/help-using-pca9685-to-control-leds/856621/9 "2021-09-02T01:48:31Z")

</div>

Closed on September 2, 2021, 1:48am UTC

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.
