Hi guys,
I've got a question. This program kept me wondering why I see two different duty cycles after setting the PWM period.
//Fiddling with the mbed PWM
#include "mbed.h"
PwmOut led(LED1);
Serial pc(USBTX, USBRX); // tx, rx
int main() {
pc.printf("testing...\n"); //testing serial port
led.write(0.5f); //output duty cycle percentage (float)
pc.printf("LED duty cycle is %f\n", led.read());
led.period(1.0f); //PWM period in seconds (float)
pc.printf("LED duty cycle is %f\n\n", led.read());
}
Output:
testing...
LED duty cycle is 0.500000
LED duty cycle is 0.010000
Am I missing something? Why doesn't the duty cycle stay the same?
Off topic: another handy terminal application is Terminal by Bray. Worth including in the Handbook?
Link
Screenshot:
Thanks!
Hi guys,
I've got a question. This program kept me wondering why I see two different duty cycles after setting the PWM period.
Output:
Am I missing something? Why doesn't the duty cycle stay the same?
Off topic: another handy terminal application is Terminal by Bray. Worth including in the Handbook?
Link
Screenshot:
Thanks!