Final

Dependencies:   mbed

Fork of Smoke_Water by Preston Stephens

Files at this revision

API Documentation at this revision

Comitter:
pstephens18
Date:
Sun Jan 24 00:37:02 2016 +0000
Parent:
0:962d8d826218
Commit message:
Final;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Jan 20 21:45:59 2016 +0000
+++ b/main.cpp	Sun Jan 24 00:37:02 2016 +0000
@@ -2,26 +2,36 @@
 
 PwmOut buzzer(p21);
 BusOut led(LED1,LED2,LED3,LED4);
-float frequency[] = {622,0,784,0,880,0,622,0,784,0,923,880,0,622,0,784,0,880,0,784,0,622,0};
-float beat[] = {.5,0,.5,0,1.25,0,.5,0,.5,0,.5,1.5,0,.5,0,.5,0,1,0,.5,0,1.5,0};
+float frequency[] = {262,0,262,0,262,0,349,0,523,0,466,0,440,0,392,0,698,0,523,0,466,0,440,0,392,0,698,0,523,0,466,0,440,0,466,0,392,0,/**/};
+float beat[] = {.3,0,.3,0,.3,0,2,0,2,0,.3,0,.3,0,.3,0,2,0,1,0,.3,0,.3,0,.3,0,2,0,1,0,.3,0,.3,0,.3,0,2,0/**/};
+float frequency2[] = {262,0,262,0,294,0,294,0,466,0,440,0,392,0,349,0,349,0,392,0,440,0,392,0,294,0,330,0,523,0,523,0,698,0,622,0,554,0,523,0,466,0,415,0,392,0,349,0,523,0};
+float beat2[] = {.75,0,.25,0,1.5,0,.5,0,.5,0,.5,0,.5,0,.5,0,.3,0,.3,0,.3,0,1,0,.5,0,1,0,.75,0,.25,0,1,0,.5,0,1,0,.5,0,1,0,.5,0,1,0,.5,0,4,0};
 
 int main() {
     while(1) 
     {
-        for(int i=0; i<= 23;i++)
+
+        for(int i=0; i<= 37;i++)
         {
-            buzzer.period(4/(frequency[i]));
+            buzzer.period(2/(frequency[i]));
             buzzer = 0.5;
-            if(frequency[i]== 622){led =1;} 
-            if(frequency[i]== 784){led =2;} 
-            if(frequency[i]== 880){led =4;}
-            if(frequency[i]== 923){led = 8;} 
-    
+            
             wait(0.4*beat[i]); 
-            
             if(beat[i]==0)
-            {wait(.15);}
+            {wait(.05);}
           
         }
+        
+        for(int i=0; i<= 49;i++)
+        {
+            buzzer.period(2/(frequency2[i]));
+            buzzer = 0.5;
+            
+            wait(0.4*beat2[i]); 
+            if(beat2[i]==0)
+            {wait(.05);}
+          
+        }
+        
     }
 }