const int LED_PINS[] = {27,26,25,33} ;
const int NUM_PINS = sizeof(LED_PINS)/sizeof(int) ;
const int PWM_RESOLUTION = 8 ;
const int DUTY_MAX = 1 << (PWM_RESOLUTION) ;
const int PWM_FREQ = 5000 ;
const int DUTY_PERCENT[] = { DUTY_MAX /* 100% */ , DUTY_MAX*0.5 /* 50% */ , DUTY_MAX*0.25 /* 25% */, DUTY_MAX*0.1 /* 10% */ } ;
const int NUM_DUTY = sizeof(DUTY_PERCENT)/sizeof(int) ;
void setup() {
// put your setup code here, to run once:
for(int i=0 ; i < NUM_PINS ; i++) {
pinMode(LED_PINS[i] , OUTPUT);
ledcSetup(i,PWM_FREQ,PWM_RESOLUTION) ;
ledcAttachPin(LED_PINS[i],i) ;
}
}
void loop() {
for(int i=0 ; i < NUM_PINS ; i++) {
for (int x=0 ; x < NUM_DUTY ; x++){
ledcWrite(i,DUTY_PERCENT[x]);
delay(1000);
}
}
}