Simple tool for PWM piezo speaker
Diff: Piezo.h
- Revision:
- 0:39de01daa2de
- Child:
- 1:220d39711dc6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Piezo.h Sat Oct 01 19:09:55 2016 +0000 @@ -0,0 +1,35 @@ +#ifndef PIEZO +#define PIEZO + +#include "mbed.h" + +class Piezo{ + +public: + Piezo(PinName Pwmout); + + void play(float, int); + void playAsync(float, int); + + //void setFrequency(int Hz); + //void setDuration(int time_ms); + void stop(); + +private: + PwmOut _pwm; + Ticker _timer; + Ticker _updater; + + float Period; + + float min_freq; + float max_freq; + + int Duration; + void autoStop(); + + float stepMultiplier; + +}; + +#endif \ No newline at end of file