Dependencies:   mbed

Fork of PwmOut_HelloWorld by mbed_example

Committer:
MechB021
Date:
Fri Oct 07 03:55:02 2016 +0000
Revision:
2:892363315d18
Parent:
1:5160ea45399b

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:50d2b9c62765 1 #include "mbed.h"
mbedAustin 1:5160ea45399b 2
MechB021 2:892363315d18 3 PwmOut led(D5);
MechB021 2:892363315d18 4 //DigitalOut led(led);
mbedAustin 1:5160ea45399b 5
mbed_official 0:50d2b9c62765 6 int main() {
mbedAustin 1:5160ea45399b 7 // specify period first
MechB021 2:892363315d18 8 led.period(0.01f); // 4 second period
MechB021 2:892363315d18 9 led.write(0.150f); // 50% duty cycle, relative to period
mbedAustin 1:5160ea45399b 10 //led = 0.5f; // shorthand for led.write()
mbedAustin 1:5160ea45399b 11 //led.pulsewidth(2); // alternative to led.write, set duty cycle time in seconds
MechB021 2:892363315d18 12 while(1){
MechB021 2:892363315d18 13 printf("%f\n",led.read());
MechB021 2:892363315d18 14 }
mbed_official 0:50d2b9c62765 15 }