const int LED_PINS[] = {5,18,19,21};
const int NUM_LEDS = sizeof(LED_PINS)/sizeof(int);
#define OFF (LOW)
#define ON (HIGH)
void setup() {
}
const int PWM_RESOLUTION = 8;
const int PWM_FREQ = 1000;
const int DUTY_MAX = (1 << PWM_RESOLUTION);
void turn_on() {
for ( int i=0; i < NUM_LEDS; i++ ) {
ledcSetup( i /*channel*/, PWM_FREQ, PWM_RESOLUTION );
ledcAttachPin( LED_PINS[i] /*pin*/, i /*channel*/ );
for ( int x=0; x < DUTY_MAX; x++ ) {
ledcWrite( i, x );
delay(5);
}
ledcDetachPin( LED_PINS[i] );
digitalWrite( LED_PINS[i], ON );
delay(200);
}
}
void turn_off() {
for ( int i=0; i < NUM_LEDS; i++ ) {
ledcSetup( i /*channel*/, PWM_FREQ, PWM_RESOLUTION );
ledcAttachPin( LED_PINS[i] /*pin*/, i /*channel*/ );
for ( int x=0; x < DUTY_MAX; x++ ) {
ledcWrite( i, DUTY_MAX-1-x );
delay(5);
}
ledcDetachPin( LED_PINS[i] );
digitalWrite( LED_PINS[i], OFF );
delay(200);
}
}
void loop() {
turn_on();
turn_off();
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2
r4:1
r4:2
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
led4:A
led4:C