Skip to content

Instantly share code, notes, and snippets.

@HectorTorres
Created January 16, 2018 19:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HectorTorres/510b29ce45036b6cf0848b2630526d4c to your computer and use it in GitHub Desktop.
Save HectorTorres/510b29ce45036b6cf0848b2630526d4c to your computer and use it in GitHub Desktop.
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
// called this way, it uses the default address 0x40
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();
void setup() {
pwm.begin();
pwm.setPWMFreq(1600); // This is the maximum PWM frequency
}
void loop() {
for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) {//Incremento para los niveles, en este caso estamos usando 16 canales
for (uint16_t i=0; i<4096; i += 64) { //Este incremento define la velocidad del ciclo, probar con 8,16,32, etc...
pwm.setPWM(pwmnum, 0, i);
//Primer parametro es el LED a encender,
//Segundo: Valor inicial de PWM.
//Tercero: Valor final, en este caso es variable ya que se usa como dimmer
}
}
for (uint8_t pwmnum=0; pwmnum < 16; pwmnum++) { //Ciclo para borrar los LEDs
pwm.setPWM(16-pwmnum, 0, 4096 );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment