#include <stdio.h>
#include "driver/ledc.h"
#include "esp_err.h"
#define SingleShotOutput 2
#define PWMchannel 1
void IRAM_ATTR pwmstop()
{
ledcWrite(PWMchannel, 0);
}
void setup()
{
ledcAttachPin(SingleShotOutput, PWMchannel);
ledcSetup(PWMchannel, 10, 8); // 10 Hz PWM (100ms), 8-bit resolution
attachInterrupt(digitalPinToInterrupt(SingleShotOutput), pwmstop, FALLING);
}
void loop()
{
ledcWrite(PWMchannel, 128); //50% duty cycle to achieve 50ms on-time
delay(2000); // Wait a long time to restart the single pulse again
}