int led_pins[] = {15,2,4,5,18,19,21,22};
int num_leds = sizeof(led_pins)/sizeof(int);
void setup() {
Serial.begin(115200);
for ( int i=0; i<num_leds; i++ ) {
ledcSetup(i, 5000, 8);
}
}
int leda = 3;
int ledb = 2;
int ledc = 1;
int ledd = 0;
void loop() {
for (int j = 0;j<num_leds;j++){
Serial.print("---------------------------------------------------------\n");
if(leda==num_leds){
leda = 0;
}
if(ledb==num_leds){
ledb = 0;
}
if(ledc==num_leds){
ledc = 0;
}
if(ledd==num_leds){
ledd = 0;
}
ledcAttachPin(led_pins[leda], leda);
ledcWrite(leda,255); //100%255
Serial.printf( "leda: %d\n", leda );
ledcAttachPin(led_pins[ledb], ledb);
ledcWrite(ledb,191.25); //75%191.25
Serial.printf( "ledb: %d\n", ledb );
ledcAttachPin(led_pins[ledc], ledc);
ledcWrite(ledc,127.5); //50%127.5
Serial.printf( "ledc: %d\n", ledc );
ledcAttachPin(led_pins[ledd], ledd);
ledcWrite(ledd,1); //25%63.75
Serial.printf( "ledd: %d\n", ledd );
delay(500);
ledcDetachPin(led_pins[leda]);
ledcDetachPin(led_pins[ledb]);
ledcDetachPin(led_pins[ledc]);
ledcDetachPin(led_pins[ledd]);
leda++;
ledb++;
ledc++;
ledd++;
}
}