Own PWM lib
Diff: PWM.cpp
- Revision:
- 0:a30a502e0c75
--- /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