plays a fucking annoying sound for 10 seconds and loops.
Dependencies: mbed
Fork of song_demo_PWM by
Diff: SongPlayer.h
- Revision:
- 3:89b8dea1cf17
- Parent:
- 1:2e6ea42675c7
diff -r 2cca82c058fc -r 89b8dea1cf17 SongPlayer.h --- a/SongPlayer.h Tue Oct 27 10:06:16 2015 +0000 +++ b/SongPlayer.h Tue Oct 27 13:30:31 2015 +0000 @@ -1,4 +1,5 @@ #include "mbed.h" +bool keepplaying = true; // new class to play a note on Speaker based on PwmOut class class SongPlayer { @@ -30,12 +31,14 @@ //Interrupt Routine to play next note void SongPlayer::nextnote() { - _pin = 0.0; - notecount++; //setup next note in song - if (durationptr[notecount]!=0.0) { - _pin.period(1.0/frequencyptr[notecount]); - noteduration.attach(this,&SongPlayer::nextnote, durationptr[notecount]); - _pin = vol/2.0; - } else - _pin = 0.0; //turn off on last note + if(keepplaying==true){ + _pin = 0.0; + notecount++; //setup next note in song + if (durationptr[notecount]!=0.0) { + _pin.period(1.0/frequencyptr[notecount]); + noteduration.attach(this,&SongPlayer::nextnote, durationptr[notecount]); + _pin = vol/2.0; + } else + _pin = 0.0; //turn off on last note + } } \ No newline at end of file