Plays the happy birthday song music on the speaker.
Dependencies: DebounceInterrupts mbed
DebouncedIn.h@0:33ad8330e62d, 2014-06-10 (annotated)
- Committer:
- bhakti08
- Date:
- Tue Jun 10 21:53:29 2014 +0000
- Revision:
- 0:33ad8330e62d
Happy Birthday Song using mbed;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bhakti08 | 0:33ad8330e62d | 1 | #include "mbed.h" |
bhakti08 | 0:33ad8330e62d | 2 | |
bhakti08 | 0:33ad8330e62d | 3 | class DebouncedIn { |
bhakti08 | 0:33ad8330e62d | 4 | public: |
bhakti08 | 0:33ad8330e62d | 5 | DebouncedIn(PinName in); |
bhakti08 | 0:33ad8330e62d | 6 | |
bhakti08 | 0:33ad8330e62d | 7 | int read (void); |
bhakti08 | 0:33ad8330e62d | 8 | operator int(); |
bhakti08 | 0:33ad8330e62d | 9 | |
bhakti08 | 0:33ad8330e62d | 10 | int rising(void); |
bhakti08 | 0:33ad8330e62d | 11 | int falling(void); |
bhakti08 | 0:33ad8330e62d | 12 | int steady(void); |
bhakti08 | 0:33ad8330e62d | 13 | |
bhakti08 | 0:33ad8330e62d | 14 | private : |
bhakti08 | 0:33ad8330e62d | 15 | // objects |
bhakti08 | 0:33ad8330e62d | 16 | DigitalIn _in; |
bhakti08 | 0:33ad8330e62d | 17 | Ticker _ticker; |
bhakti08 | 0:33ad8330e62d | 18 | |
bhakti08 | 0:33ad8330e62d | 19 | // function to take a sample, and update flags |
bhakti08 | 0:33ad8330e62d | 20 | void _sample(void); |
bhakti08 | 0:33ad8330e62d | 21 | |
bhakti08 | 0:33ad8330e62d | 22 | // counters and flags |
bhakti08 | 0:33ad8330e62d | 23 | int _samples; |
bhakti08 | 0:33ad8330e62d | 24 | int _output; |
bhakti08 | 0:33ad8330e62d | 25 | int _output_last; |
bhakti08 | 0:33ad8330e62d | 26 | int _rising_flag; |
bhakti08 | 0:33ad8330e62d | 27 | int _falling_flag; |
bhakti08 | 0:33ad8330e62d | 28 | int _state_counter; |
bhakti08 | 0:33ad8330e62d | 29 | |
bhakti08 | 0:33ad8330e62d | 30 | }; |
bhakti08 | 0:33ad8330e62d | 31 |