
Pt. 4 | Encryption encrypt program
Dependencies: mbed 4DGL-uLCD-SE SDFileSystem PinDetect
Speaker.h@0:72aeef60e1fc, 2019-01-03 (annotated)
- Committer:
- sralph3
- Date:
- Thu Jan 03 22:40:26 2019 +0000
- Revision:
- 0:72aeef60e1fc
Pt. 4 | Encryption encrypt program
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sralph3 | 0:72aeef60e1fc | 1 | #include "mbed.h" |
sralph3 | 0:72aeef60e1fc | 2 | // new class to play a note on Speaker based on PwmOut class |
sralph3 | 0:72aeef60e1fc | 3 | class Speaker |
sralph3 | 0:72aeef60e1fc | 4 | { |
sralph3 | 0:72aeef60e1fc | 5 | public: |
sralph3 | 0:72aeef60e1fc | 6 | Speaker(PinName pin) : _pin(pin) { |
sralph3 | 0:72aeef60e1fc | 7 | // _pin(pin) means pass pin to the Speaker Constructor |
sralph3 | 0:72aeef60e1fc | 8 | } |
sralph3 | 0:72aeef60e1fc | 9 | // class method to play a note based on PwmOut class |
sralph3 | 0:72aeef60e1fc | 10 | void PlayNote(float frequency, float duration, float volume) { |
sralph3 | 0:72aeef60e1fc | 11 | _pin.period(1.0/frequency); |
sralph3 | 0:72aeef60e1fc | 12 | _pin = volume/2.0; |
sralph3 | 0:72aeef60e1fc | 13 | wait(duration); |
sralph3 | 0:72aeef60e1fc | 14 | _pin = 0.0; |
sralph3 | 0:72aeef60e1fc | 15 | } |
sralph3 | 0:72aeef60e1fc | 16 | |
sralph3 | 0:72aeef60e1fc | 17 | private: |
sralph3 | 0:72aeef60e1fc | 18 | PwmOut _pin; |
sralph3 | 0:72aeef60e1fc | 19 | }; |