![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Demo of wheel of fortune
Dependencies: 4DGL-uLCD-SE mbed
Speaker.h@0:1d41011a2be1, 2016-05-04 (annotated)
- Committer:
- najeekitchens
- Date:
- Wed May 04 00:06:30 2016 +0000
- Revision:
- 0:1d41011a2be1
Wheel of Fortune
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
najeekitchens | 0:1d41011a2be1 | 1 | #include "mbed.h" |
najeekitchens | 0:1d41011a2be1 | 2 | // new class to play a note on Speaker based on PwmOut class |
najeekitchens | 0:1d41011a2be1 | 3 | class Speaker |
najeekitchens | 0:1d41011a2be1 | 4 | { |
najeekitchens | 0:1d41011a2be1 | 5 | public: |
najeekitchens | 0:1d41011a2be1 | 6 | Speaker(PinName pin) : _pin(pin) { |
najeekitchens | 0:1d41011a2be1 | 7 | // _pin(pin) means pass pin to the Speaker Constructor |
najeekitchens | 0:1d41011a2be1 | 8 | } |
najeekitchens | 0:1d41011a2be1 | 9 | // class method to play a note based on PwmOut class |
najeekitchens | 0:1d41011a2be1 | 10 | void PlayNote(float frequency, float duration, float volume) { |
najeekitchens | 0:1d41011a2be1 | 11 | _pin.period(1.0/frequency); |
najeekitchens | 0:1d41011a2be1 | 12 | _pin = volume/2.0; |
najeekitchens | 0:1d41011a2be1 | 13 | wait(duration); |
najeekitchens | 0:1d41011a2be1 | 14 | _pin = 0.0; |
najeekitchens | 0:1d41011a2be1 | 15 | } |
najeekitchens | 0:1d41011a2be1 | 16 | |
najeekitchens | 0:1d41011a2be1 | 17 | private: |
najeekitchens | 0:1d41011a2be1 | 18 | PwmOut _pin; |
najeekitchens | 0:1d41011a2be1 | 19 | }; |