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

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
djinn77
Date:
Thu Nov 15 05:05:09 2018 +0000
Commit message:
Himno alegria

Changed in this revision

himno_alegria.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Nov 15 05:05:09 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file