With this library it is possible to have up to 20 pwm outputs on the digital pins of the development boards and microcontrollers compatible with STM32 for Arduino.
To work with the library, it must be included in the following way:
Code: Select all
#include "softPwmStm32.h"
Code: Select all
void setup() {
softPwmSTM32Init();
softPwmSTM32Attach(LED_BUILTIN,0);
}
To update the pwm of our pin we use the softPwmSTM32Set function, as shown in the following example:
Code: Select all
void loop() {
for(uint8_t i=0;i<100;i++){
softPwmSTM32Set(LED_BUILTIN,i);
delay(2);
}
for(uint8_t i=100;i>0;i--){
softPwmSTM32Set(LED_BUILTIN,i);
delay(2);
}
}
Code: Select all
softPwmSTM32Dettach(LED_BUILTIN);