WLED/usermods/pwm_outputs/readme.md
Ardi Loot bd601ad2da
PWM outputs usermod (#2912)
* first commit of PWM outputs

* fix pin deallocation issue

* refactoring

* removed debug prints

* fix compile error

* added readme

* added compile error for ESP8266

* added overloaded SetDuty method

* convert state to separate nested object

* Revert "added overloaded SetDuty method"

This reverts commit e8ea32f577.

* move constant strings to flash

* reworked json info and config

* bugfixes

* more bugfixes

* updated readme

* use C strings instead of String

* added uint8 and uint16 overloads for SetDuty

* removed ambiguous overload
2022-11-30 09:15:07 +01:00

28 lines
947 B
Markdown

# PWM outputs
v2 Usermod to add generic PWM outputs to WLED. Usermode could be used to control servo motors, LED brightness or any other device controlled by PWM signal.
## Installation
Add the compile-time option `-D USERMOD_PWM_OUTPUTS` to your `platformio.ini` (or `platformio_override.ini`). By default upt to 3 PWM outputs could be configured, to increase that limit add build argument `-D USERMOD_PWM_OUTPUT_PINS=10` (replace 10 by desired amount).
Currently only ESP32 is supported.
## Configuration
By default PWM outputs are disabled, navigate to Usermods settings and configure desired PWM pins and frequencies.
## Usage
If PWM output is configured, it starts to publish its duty cycle value (0-1) both to state JSON and to info JSON (visible in UI info panel). To set PWM duty cycle, use JSON api (over HTTP or over Serial)
```json
{
"pwm": {
"0": {"duty": 0.1},
"1": {"duty": 0.2},
...
}
}
```