OS2 version of the classic PwmOut

Dependencies:   mbed

Committer:
RalphF
Date:
Tue Sep 11 15:39:08 2018 +0000
Revision:
0:94058fd41b33
This is an OS2 version of the PwmOut handbook example: ; https://os.mbed.com/handbook/PwmOut; The published version was bumped to OS5.;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
RalphF 0:94058fd41b33 1 #include "mbed.h"
RalphF 0:94058fd41b33 2
RalphF 0:94058fd41b33 3 PwmOut led(LED1);
RalphF 0:94058fd41b33 4
RalphF 0:94058fd41b33 5 int main() {
RalphF 0:94058fd41b33 6 // specify period first
RalphF 0:94058fd41b33 7 led.period(4.0f); // 4 second period
RalphF 0:94058fd41b33 8 led.write(0.50f); // 50% duty cycle, relative to period
RalphF 0:94058fd41b33 9 //led = 0.5f; // shorthand for led.write()
RalphF 0:94058fd41b33 10 //led.pulsewidth(2); // alternative to led.write, set duty cycle time in seconds
RalphF 0:94058fd41b33 11 while(1);
RalphF 0:94058fd41b33 12 }