// #include <Arduino.h>
// // #define USE_LEDC
// #define LED 15
// // setting PWM properties
// const int ledPin = LED;
// const int freq = 8000;
// const int ledChannel = 0;
// const int resolution = 8;
// void setup(){
// Serial.begin(115200);
// Serial.println("Hello, Wokwi!");
// #ifdef USE_LEDC
// // configure LED PWM functionalitites
// ledcSetup(ledChannel, freq, resolution);
// ledcAttachPin(ledPin, ledChannel);
// ledcWrite(ledPin,0);
// #else
// // pinMode(ledPin, OUTPUT);
// #endif
// }
// void loop() {
// #ifdef USE_LEDC
// ledcWrite(ledPin,0);
// delay(1000);
// ledcWrite(ledPin,255);
// delay(1000);
// #else
// analogWrite(ledPin, 0);
// delay(1000);
// analogWrite(ledPin, 255);
// delay(1000);
// // digitalWrite(ledPin, LOW);
// // delay(90);
// // digitalWrite(ledPin, HIGH);
// // delay(10);
// #endif
// }
// the number of the LED pin
const int ledPin = 16; // 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);
}
}
Loading
esp32-s3-devkitc-1
esp32-s3-devkitc-1