const int ledPin = 16; //LED attached to the GPIO16 (RX2) pin on ESP32 development board //PWM properties: const int freq = 5000; const int ledChannel = 0; const int resolution = 8; void setup(){ ledcSetup(ledChannel, freq, resolution);//LED PWM functionalitites ledcAttachPin(ledPin, ledChannel);//attach the channel to GPIO to be controlled } void loop(){ //changing LED brightness with PWM for(int dutyCycle = 0; dutyCycle <= 255; dutyCycle++){ //increase LED brightness ledcWrite(ledChannel, dutyCycle);//changing the LED brightness with PWM delay(15); } for(int dutyCycle = 255; dutyCycle >= 0; dutyCycle--){//decrease LED brightness ledcWrite(ledChannel, dutyCycle); delay(15); } }