Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
11 years, 8 months ago.
PwmOut set period
Hy, I am trying to set the period for the PWM in the while(1) but it doesn't work. Ihave the following code:
- include "mbed.h"
PwmOut myled(p21);
int main() {
myled.pulsewidth_ms(3);
while(1) {
myled.period_ms(1000);
} }
Has anybody some suggestions? Thank you and regards
1 Answer
11 years, 8 months ago.
Try setting also the pulsewidth in your while loop. The LPC1768 currently doesn't keep the duty cycle equal when changing the period, so with 3ms pulsewidth and 1000ms period it probably flashes very short once per second.