Hi!
I'm a newbie to the forums as well as Arduino and electronics in general. My knowledge is very rudimentary.
I've noticed a lot of the information on line regarding Adafruit's PCA9685 is just about servos. However, I'd like to use it to power an array of LEDs, fading at different rates.
I have an Arduino Leonardo as well as an Uno. I also have a Teensy 3.0.
Thanks!
Steve
PCA9685 for LEDs
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_mike
- Posts: 67454
- Joined: Thu Feb 11, 2010 2:51 pm
Re: PCA9685 for LEDs
The PCA9685 will work for LEDs too, and can take signals from any Arduino. The exact connections will depend on the length and width of the array you want to drive though.
-
- Posts: 3
- Joined: Fri Oct 05, 2012 7:27 am
Re: PCA9685 for LEDs
Thanks! Can you recommend any code for creating a fading array? I was thinking of something like this:
http://arduino.cc/en/Tutorial/Array
But include the out-of-sync fading that I was describing earlier.
Also, how would this work with the PCA9685? Does it have to be connected to the Arduino at all times to work?
http://arduino.cc/en/Tutorial/Array
But include the out-of-sync fading that I was describing earlier.
Also, how would this work with the PCA9685? Does it have to be connected to the Arduino at all times to work?
- adafruit_support_mike
- Posts: 67454
- Joined: Thu Feb 11, 2010 2:51 pm
Re: PCA9685 for LEDs
I don't know of an LED fading library that works with that specific chip, but the servo library for that board (https://github.com/adafruit/Adafruit-PW ... er-Library) gives you enough pieces to build a working fade system. You can set the overall PWM frequency, and tell each of the 16 channels what PWM duty cycle to use.togethernessnyc wrote:Thanks! Can you recommend any code for creating a fading array?
An untested, off-the-top-of-my-head version of the algorithm for a single channel would look like this:
Code: Select all
int channel = 1;
int fadeAge = 0;
int direction = 1;
void loop () {
if (fadeAge > 2047) {
direction = -1;
}
if (fadeAge < 1) {
direction = 1;
}
fadeAge += direction;
setPWM( channel, 2048 - fadeAge, 2048 + fadeAge );
delay( 10 );
}
To fade, yes. To keep the LEDs going at a specific level, no.togethernessnyc wrote:Also, how would this work with the PCA9685? Does it have to be connected to the Arduino at all times to work?
The PCA9685 is a 'free running' PWM controller. Tell it what to do, and it will keep doing that until you tell it to do something else. If you wanted to set the LEDs to a specific intensity and keep them there, you could disconnect the Arduino until you wanted the LEDs to do something else. To make a fade work, you have to keep changing the duty cycles at short time intervals so people see a smooth change from low-intensity light to high-intensity light. The Arduino has to remain connected to keep supplying the new values.
-
- Posts: 3
- Joined: Fri Oct 05, 2012 7:27 am
Re: PCA9685 for LEDs
@mstone, Thanks! I just downloaded the servo library. I'm going to play around with your code a bit.
Re: constant fade/Arduino, understood! A little BANNED, but so it goes
Re: constant fade/Arduino, understood! A little BANNED, but so it goes
Please be positive and constructive with your questions and comments.