adafruit / Adafruit_CircuitPython_PCA9685

Adafruit CircuitPython driver for PCA9685 16-channel, 12-bit PWM LED & servo driver chip.
MIT License
120 stars 64 forks source link

Is there a way to manually turn Pins on/off? #60

Open mxx-lxg opened 4 months ago

mxx-lxg commented 4 months ago

I'm trying to control an RC car and i#ve run into a road block so to say. The cars speed controller needs an activation signal before accepting any PWM signal. That activation signal isn't PWM, but a specific pattern. So my question is, is there any way to turn a Channel on and off manually, so i can put together the activation signal i need?

caternuson commented 4 months ago

Yes. On and off are just the limiting case for 100% and 0% duty cycle. The PCA9685 itself has a special bit in the duty cycle registers: image

To use this via this library, set duty cycle to 0xFFFF for ON and 0 for OFF.

https://docs.circuitpython.org/projects/pca9685/en/latest/api.html#adafruit_pca9685.PWMChannel.duty_cycle 0xffff will always be high, 0 will always be low

Whether this will work or not for your particular setup is something you'll need to test. If the pattern has very specific timing requirements, then it may be tricky.