Este codigo genera el himno de la alegria mediante un piezo electrico

Dependencies:   mbed

Revision:
0:4dc7ef5de2da
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/himno_alegria.cpp	Thu Nov 15 05:05:09 2018 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+
+PwmOut buzzer(A1);
+
+int periodos1[]={1516,1431,1275,1275,1431,1516,1702,1911,1911,1702,1516,1516,1702};
+int periodos2[]={1516,1431,1275,1275,1431,1516,1702,1911,1911,1702,1516,1702,1911};
+int periodos3[]={1702,1516,1911,1702,1516,1431,1516,1911,1702,1516,1431,1516,1702,1911,1702,1275};
+double duracion1[]={2,1,1,1,1,1,1,1,1,1,1,2,2};
+double duracion2[]={2,1,1,1,0.5,0.5,1,1,1,0.5,0.5,1,1,1,1,2};
+
+int i;
+int main(){
+    while(1){
+        buzzer=0.2;
+        for (i=0; i<13; i++) {
+            buzzer.period_us(periodos1[i]);
+            wait(0.5*duracion1[i]);
+        }
+        for (i=0; i<13; i++) {
+            buzzer.period_us(periodos2[i]);
+            wait(0.5*duracion1[i]);
+        }
+        for (i=0; i<16; i++) {
+            buzzer.period_us(periodos3[i]);
+            wait(0.5*duracion2[i]);
+        }
+    }
+}
\ No newline at end of file