const int LED_PINS[] = {5,18,19,21};
const int NUM_LEDS = sizeof(LED_PINS)/sizeof(int);
#define OFF (HIGH) // active-low LED
void setup() {
for ( int i=0; i < NUM_LEDS; i++ ) {
// set the direction of the i-th LED pin
pinMode( LED_PINS[i], OUTPUT );
digitalWrite( LED_PINS[i], OFF );
}
}
const int PWM_RESOLUTION = 8;
const int PWM_FREQ = 1000;
const int DUTY_MAX = (1 << PWM_RESOLUTION);
void loop() {
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-x );
delay(1);
}
}
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(1);
}
ledcDetachPin( LED_PINS[i] );
digitalWrite( LED_PINS[i], OFF );
}
}
esp32:VIN
esp32:GND.2
esp32:D13
esp32:D12
esp32:D14
esp32:D27
esp32:D26
esp32:D25
esp32:D33
esp32:D32
esp32:D35
esp32:D34
esp32:VN
esp32:VP
esp32:EN
esp32:3V3
esp32:GND.1
esp32:D15
esp32:D2
esp32:D4
esp32:RX2
esp32:TX2
esp32:D5
esp32:D18
esp32:D19
esp32:D21
esp32:RX0
esp32:TX0
esp32:D22
esp32:D23
r8:1
r8:2
r9:1
r9:2
r10:1
r10:2
led1:A
led1:C
led2:A
led2:C
led3:A
led3:C
led4:A
led4:C
r1:1
r1:2