en-us_commands:reference:pwmoff
Table of Contents
PWMOFF()
Commands
| Command | Arguments | Return Value | Operation |
|---|---|---|---|
PWMOFF(pin, POff) | uint8_t pinbool POff | void | Stops or re-enables PWM output on the specified pin. |
Example
This example uses MPINO-16A8R8T PWM output D11 and digital input D22. HIGH on D22 stops PWM; LOW allows it again. This input demonstrates the function and does not replace an equipment emergency-stop device.
const uint8_t PWM_PIN = 11; void setup() { FDPWM(PWM_PIN, 1000, 50.0F); // Start 1 kHz PWM at 50% duty on D11. } void loop() { const bool stopRequest = digitalRead(22) == HIGH; PWMOFF(PWM_PIN, stopRequest); // Stop or allow D11 PWM according to D22. if (!stopRequest) FDPWM(PWM_PIN, 1000, 50.0F); // Apply PWM settings again after allowing the output. delay(20); }
Precautions
- Check product-specific PWM pins and timer sharing.
- Changing frequency or resolution may also affect other channels on the same timer.
- Ensure the connected load is safe when stopping or resetting outputs.
Built-in Commands in the Same Category
en-us_commands/reference/pwmoff.txt · Last modified: by 127.0.0.1
