Pulse Width Modulation (PWM)

1. Introduction

In the steps of this tutorial

  1. a single PWM signal is generated, and
  2. multiple PWM signals are generated.

2. Prerequisites

3. Basics

The basic of PWM are described on Wikipedia: https://en.wikipedia.org/wiki/Pulse-width_modulation

The Espressif ESP32C3 has a dedicated hardware module, which can generate PWM signals. The Espressif ESP32C3 PWM hardware module is called LED Control (LEDC) and described in the Espressif documentation: https://docs.espressif.com/projects/esp-idf/en/stable/esp32c3/api-reference/peripherals/ledc.html

The library to control the ESP32C3’s LED Control module is described in the Espressif’s GitHub repository: https://github.com/espressif/arduino-esp32/blob/master/docs/en/api/ledc.rst

4. Implementation

4.1 Single PWM Signal Output

Example code: pwm_ledc

4.2 Multi PWM Signal Output

Example code: pwm_ledc_2pins