#if 0
#include <Arduino.h>

const int PWM_pin = GPIO_NUM_2;  //GPIO 2 - vstavana LED 

// parametre PWM
const int freq = 5000;
const int PWM_channel = 0;
const int resolution = 8;
int dutyCycle = 200;

void setup()
{
    Serial.begin(115200);
    // konfigurácia PWM
    ledcSetup(PWM_channel, freq, resolution);

    //pripojenie kanálu k GPIO pinu, ktorý chceme ovládať
    ledcAttachPin(PWM_pin, PWM_channel);
    //test
    ledcWrite(PWM_channel, dutyCycle);
    delay(1000);
    ledcWrite(PWM_channel, dutyCycle);
}

void loop()
{
    //zvyšovanie striedy
    for(int dutyCycle = 0; dutyCycle <= 255; dutyCycle++){   
        ledcWrite(PWM_channel, dutyCycle);
        delay(100);
    }

    //znižovanie striedy
    for(int dutyCycle = 255; dutyCycle >= 0; dutyCycle--){
        ledcWrite(PWM_channel, dutyCycle);   
        delay(100);
    }

    //PWM dutyCycle, vstup z konzoly
    #if 0 
    if(Serial.available()>0) 
    {
        dutyCycle = Serial.parseInt();
        Serial.print("PWM duty cycle = ");
        Serial.println(dutyCycle);
    }
    ledcWrite(PWM_channel, dutyCycle);
    #endif
}

#endif