#define LED1 21
/* setting PWM properties */
const int freq = 5000;
const byte ledChannel = 0;
const byte resolution = 8;
void setup(){
ledcSetup(ledChannel, freq, resolution);
ledcAttachPin(LED1, ledChannel);
}
void loop(){
for(int duty = 0; duty <= 255; duty++){
ledcWrite(ledChannel, duty);
delay(15);
}
for(int duty = 255; duty >=0; duty--){
ledcWrite(ledChannel, duty);
delay(15);
}
}
#define LED1 21
#define LED2 19
#define LED3 18
#define LED4 5
byte fade[] = {0,0,0,0,200,255, 200, 150, 100, 50, 10, 0, 0, 0,0};
void setup() {
ledcSetup(0, 5000, 8); /*ledcSetup(Channel,Freq,Resolution) */
ledcSetup(1, 5000, 8);
ledcSetup(2, 5000, 8);
ledcSetup(3, 5000, 8);
ledcAttachPin(LED1, 0); /*ledcAttachPin(Pin,Channel) */
ledcAttachPin(LED2, 1);
ledcAttachPin(LED3, 2);
ledcAttachPin(LED4, 3);
}
void loop() {
for (int i = 0; i < 11; i++) {
ledcWrite(0, fade[i]);
ledcWrite(1, fade[i + 1]);
ledcWrite(2, fade[i + 2]);
ledcWrite(3, fade[i + 3]);
delay(75);
}
}