// #include <Arduino.h>
// #define LED_BUILTIN 15
// void setup() {
// // put your setup code here, to run once:
// pinMode(LED_BUILTIN, OUTPUT);
// Serial.begin(115200);
// Serial.println("Hello, ESP32!");
// }
// void loop() {
// // put your main code here, to run repeatedly:
// delay(1000);
// digitalWrite(LED_BUILTIN, HIGH);
// Serial.println("I am Chaitanya");
// delay(1000);
// digitalWrite(LED_BUILTIN, LOW);
// }
// the number of the LED pin
const int ledPin = 15; // 16 corresponds to GPIO16
// const int ledPin2 = 17; // 17 corresponds to GPIO17
// const int ledPin3 = 5; // 5 corresponds to GPIO5
// setting PWM properties
const int freq = 5000;
const int ledChannel = 0;
const int resolution = 8;
void setup(){
// configure LED PWM functionalitites
ledcSetup(ledChannel, freq, resolution);
// attach the channel to the GPIO to be controlled
ledcAttachPin(ledPin, ledChannel);
// ledcAttachPin(ledPin2, ledChannel);
// ledcAttachPin(ledPin3, ledChannel);
}
void loop(){
// increase the LED brightness
for(int dutyCycle = 0; dutyCycle <= 255; dutyCycle++){
// changing the LED brightness with PWM
ledcWrite(ledChannel, dutyCycle);
delay(15);
}
// decrease the LED brightness
for(int dutyCycle = 255; dutyCycle >= 0; dutyCycle--){
// changing the LED brightness with PWM
ledcWrite(ledChannel, dutyCycle);
delay(15);
}
}