IoT for mbed1
Dependencies: 4DGL-uLCD-SE IoTsecuritySys PinDetect mbed-rtos mbed
Fork of IoT by
Speaker.h@9:413c094dd1e2, 2015-12-08 (annotated)
- Committer:
- jsmith352
- Date:
- Tue Dec 08 23:28:24 2015 +0000
- Revision:
- 9:413c094dd1e2
- Parent:
- 1:7f873efe5b11
IoT for mbed1
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
landes | 1:7f873efe5b11 | 1 | #include "mbed.h" |
landes | 1:7f873efe5b11 | 2 | // new class to play a note on Speaker based on PwmOut class |
landes | 1:7f873efe5b11 | 3 | class Speaker |
landes | 1:7f873efe5b11 | 4 | { |
landes | 1:7f873efe5b11 | 5 | public: |
landes | 1:7f873efe5b11 | 6 | Speaker(PinName pin) : _pin(pin) { |
landes | 1:7f873efe5b11 | 7 | // _pin(pin) means pass pin to the Speaker Constructor |
landes | 1:7f873efe5b11 | 8 | } |
landes | 1:7f873efe5b11 | 9 | // class method to play a note based on PwmOut class |
landes | 1:7f873efe5b11 | 10 | void PlayNote(float frequency, float duration, float volume) { |
landes | 1:7f873efe5b11 | 11 | _pin.period(1.0/frequency); |
landes | 1:7f873efe5b11 | 12 | _pin = volume;///2.0; |
landes | 1:7f873efe5b11 | 13 | wait(duration); |
landes | 1:7f873efe5b11 | 14 | _pin = 0.0; |
landes | 1:7f873efe5b11 | 15 | } |
landes | 1:7f873efe5b11 | 16 | |
landes | 1:7f873efe5b11 | 17 | private: |
landes | 1:7f873efe5b11 | 18 | PwmOut _pin; |
landes | 1:7f873efe5b11 | 19 | }; |