Pulse Width Modulation (PWM) is a method to create an analog-like signal from the microcontroller's digital output. It achieves that by fast toggling of the pin with a different ratio of logic HIGH and LOW. This ratio is called the duty cycle.
Please check the Core Module pinout to see which pins allow PWM.
9 pins can be used as PWM pins:
- PWM SDK Module
- GitHub Repository Example
The duty cycle stands for how long should the pin be in the HIGH state, by changing this number you will achieve different analog-like outputs.
The values range from
0 means always LOW and
255 means always HIGH
This is just a simple example that will enable PWM signal on P6, P7 and P8 outputs. Every output has a different duty cycle: 180, 210 and 255.
Run PWM on Pins Code Example