Mbed Clock application using an NTP connection to get internet time and a terminal interface to send commands
Dependencies: 4DGL-uLCD-SE EthernetInterface NTPClient mbed-rtos mbed SDFileSystem wavfile
Diff: Speaker.h
- Revision:
- 2:c939d0501184
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Speaker.h Mon Dec 08 23:30:49 2014 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" +// new class to play a note on Speaker based on PwmOut class +class Speaker +{ +private: +// sets up specified pin for PWM using PwmOut class + PwmOut pin; + Ticker ticker; + void flipPin() { + pin = 0.0; + } +public: + Speaker(PinName pin) : pin(pin) { +// _pin(pin) means pass pin to the Speaker Constructor + } +// class method to play a note based on PwmOut class + void playNote(float frequency, float duration, float volume) { + pin.period(1.0/frequency); + pin = volume/2.0; + ticker.attach(this, &Speaker::flipPin, duration); + //wait(duration); + //pin = 0.0; + } + +}; + \ No newline at end of file