PCA9685 - control 16 LED with PWM

Hi all,

I have placed LED on each step of my house stairs, and now I want to light them up one by one when turn the light on:
when turn the light on downstairs to light them up one by one with fade from step 1 to 16 and when turn the light on from upstairs to light them up with fade effect from 16 to 0…
For this I have arduino uno or Mega and bought from aliexpress PCA9685 to achieve this.

I have started from Adafruit 16-channel PWM & Servo driver pwm test and trying to understand how is working but I have difficulties controlling the LED

I am playing with this code and 3 LED but when i power on the arduino the LED are on and flashing one by one. If i delete the code from Loop led’s are on.

i want to have them off and light them one by one.
I have connected the LED to ground and PWM on PCA9685 using resistor

/*************************************************** 
  This is an example for our Adafruit 16-channel PWM & Servo driver
 ****************************************************/

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

void setup() {
  
  Serial.begin(9600);
  pwm.begin();
  pwm.setPWMFreq(500);  // This is the maximum PWM frequency
}

void loop()
{
 
  for (int j=0; j<3; j++ )
  {
    for (int i=0; i<4095; i+=1)
    {
     pwm.setPWM(j,1, i);
 
    }
    }
}

I think youre getting what you want , it just happens too fast to see it.
add a short delay() after the setPWM()....say 5 ms initially.

Hi,

I did add the delay and a PIR sensor to be sure will start turning on the light when I like.
how can i keep the led on without blinking… after it turn on all 3 LED is doing a blink for each one… will like to keep them on and when i like to turn them off one by one…

/*************************************************** 
  This is an example for our Adafruit 16-channel PWM & Servo driver
 ****************************************************/

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
int pirPin = 2;
int parter;

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

void setup() {
  
  Serial.begin(9600);
  pwm.begin();
  delay(5000);
  pwm.setPWMFreq(500);  // This is the maximum PWM frequency
}

void loop()
{
  parter=digitalRead(pirPin); //read state of the PIR
  if (parter == LOW)
       {
         Serial.println("miscare parter");
         for (int j=0; j<3; j++ )
                {
                for (int i=0; i<4095; i+=4)
                 {
                pwm.setPWM(j,1, i);
                }
      }
}
}

Any idea how should I do to dim out the LED's when turn off?