esp32_pwm_example.cpp
#include <Arduino.h>
#include <driver/ledc.h>
void setup() {
Serial.begin(115200);
ledcSetup(LEDC_CHANNEL_0, 10000 /* Hz */, 12);
ledcAttachPin(GPIO_NUM_14, LEDC_CHANNEL_0);
ledcWrite(LEDC_CHANNEL_0, 2048); // 50%
}
void loop() {
// Exemple de comment changer le cycle de service à 25%
ledcWrite(LEDC_CHANNEL_0, 1024);
}
Consultez les articles similaires par catégorie :
Arduino ESP8266/ESP32 PlatformIO
Si cet article vous a aidé, pensez à m'offrir un café ou à faire un don via PayPal pour soutenir la recherche et la publication de nouveaux articles sur TechOverflow