Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:a30a502e0c75, committed 2016-04-10
- Comitter:
- Drohne
- Date:
- Sun Apr 10 11:42:37 2016 +0000
- Commit message:
- PWM
Changed in this revision
PWM.cpp | Show annotated file Show diff for this revision Revisions of this file |
PWM.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r a30a502e0c75 PWM.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PWM.cpp Sun Apr 10 11:42:37 2016 +0000 @@ -0,0 +1,13 @@ +#include "mbed.h" +#include "PWM.h" + +PWM::PWM(PinName pin) : _pin(pin){ + _pin = 0; + } + + void PWM::dutycycle(int period, int ontime){ + _pin = 0; + wait_us(ontime); // ontime + _pin = 1; + wait_us(period-ontime); // offtime + } \ No newline at end of file
diff -r 000000000000 -r a30a502e0c75 PWM.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/PWM.h Sun Apr 10 11:42:37 2016 +0000 @@ -0,0 +1,14 @@ +#ifndef MBED_PWM_H +#define MBED_PWM_H + +#include "mbed.h" + +class PWM { + public: + PWM(PinName pin); + void dutycycle(int period, int ontime); + + private: + DigitalOut _pin; + }; +#endif \ No newline at end of file