Arduino Forum

Using Arduino => LEDs and Multiplexing => Topic started by: altitudinem on May 28, 2018, 04:11 pm

Title: Problem with the adafruit PWM shield while dimming leds.
Post by: altitudinem on May 28, 2018, 04:11 pm
Hey, Im trying to make something with the 16ch PWM Driver - https://www.adafruit.com/product/815


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?



Code: [Select]
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>


Adafruit_PWMServoDriver pwm1 = Adafruit_PWMServoDriver(0x40);



void setup() {
  Serial.begin(9600);
  pwm1.begin();
  pwm1.setPWMFreq(1600);
  Wire.setClock(400000);
  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); 
    }
  }
}
Title: Re: Problem with the adafruit PWM shield while dimming leds.
Post by: Jobi-Wan on May 28, 2018, 05:32 pm
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.

Title: Re: Problem with the adafruit PWM shield while dimming leds.
Post by: altitudinem on May 29, 2018, 08:42 pm
Super thanks! Never thought about that. So it was off when it reached 4096