plays a fucking annoying sound for 10 seconds and loops.
Dependencies: mbed
Fork of song_demo_PWM by
Revision 7:29dd200668db, committed 2015-10-29
- Comitter:
- mganseij
- Date:
- Thu Oct 29 10:34:57 2015 +0000
- Parent:
- 6:ce3c3d9c96e9
- Commit message:
- newest version thingy
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Oct 29 10:08:17 2015 +0000
+++ b/main.cpp Thu Oct 29 10:34:57 2015 +0000
@@ -1,54 +1,26 @@
#include "mbed.h"
#include "tones.h"
#include "SongPlayer.h"
-
// I apologize in advance for this fucking mess of a code
+// Update: it's slightly less of a mess right now! :D
DigitalIn input(A4);
-PwmOut speaker(A5);
SongPlayer mySpeaker(A5);
Timer songTimer;
+Timer deathTimer;
+bool deathbool = false;
-bool playbuzz;
-
-void evalbuzz()
+void death()
{
- if(input == 1)
- {
- playbuzz = true;
- }
- else
- {
- playbuzz = false;
- }
+ deathTimer.reset();
+ mySpeaker.PlaySong(note_death,duration_death);
}
-void buzz()
-{
- for (int i=0; i<26; i=i+2)
- {
- evalbuzz();
- if(playbuzz == true)
- {
- speaker.period(1.0/3800.0);
- speaker = float(i)/50.0;
- wait(.2);
- speaker.period(1.0/4200.0);
- wait(.2);
- }
- else
- {
- songTimer.reset();
- mySpeaker.PlaySong(note,duration);
- break;
- }
- }
-
-}
int main()
{
songTimer.start();
+ deathTimer.start();
mySpeaker.PlaySong(note,duration);
while(1)
{
@@ -58,14 +30,14 @@
}
else
{
- keepplaying = false;
+ //keepplaying = false; commented out for now
}
- if(input == 1)
+ if(input == 1 and deathTimer.read() > 4)
{
- playbuzz = true;
- buzz();
+ death();
+
}
- if(songTimer.read() > 29.2)
+ if(songTimer.read() > 15)
{
songTimer.reset();
mySpeaker.PlaySong(note,duration);
