Problem with the adafruit PWM shield while dimming leds.

Hey, Im trying to make something with the 16ch PWM Driver - Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface [PCA9685] : ID 815 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Im testing some patterns with 16 leds, for figure out how this driver and library works.

I wrote this below for dimming 16ch leds in the same time, and it works fine but one thing.

It blinks one time at the peak brightness before it starts to dimm out.

Can somebody help me for this?

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

Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x40);

void setup() {
  for(uint16_t pin=0; pin<16; pin++){   //turn off the all leds
    pwm1.setPWM(pin, 0, 0);

void loop(){
  for(uint16_t n=0; n<=4096; n += 16){      //turn on the leds
    for(uint16_t pin=0; pin<16; pin ++){
      pwm1.setPWM(pin, 0, n);  
     for(uint16_t f=0; f<=4096; f += 16){     //turn off the leds
       for(uint16_t pin=0; pin<16; pin ++){
         pwm1.setPWM(pin, f, 0);  

12 bit means you can use values from 0 to 4095.
4096 is a 13 bit number. A one with 12 zeros. So the lower 12 bits are all zero. Those lower 12 bits are what gets transferred.

Super thanks! Never thought about that. So it was off when it reached 4096