const int ledPin=21;
const int frequency=500;
const int ledChannel=0;
const int resolution=8;
void setup() {
// put your setup code here, to run once:
//configure led pwm functionalities
ledcSetup(ledChannel,frequency,resolution);
//attach the channel to the gpio to be controlled
ledcAttachPin(ledPin,ledChannel);
}
void loop() {
// put your main code here, to run repeatedly:
//to increase led brightness
for(int dutyCycle=0;dutyCycle<=255;dutyCycle++)
{
//changing the led brightness with pwm
ledcWrite(ledChannel,dutyCycle);
delay(15);
}
}