hrv_himna

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
ipadjen
Date:
Thu Dec 10 17:58:35 2015 +0000
Commit message:
hrv_himna

Changed in this revision

main.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/main.cpp	Thu Dec 10 17:58:35 2015 +0000
@@ -0,0 +1,25 @@
+#include "mbed.h"
+PwmOut buzzer(p21);
+//frekvencija melodije "Lijepa naša"
+float frequency[]= {659.3, 659.3, 659.3, 587.3, 587.3, 523.3, 523.3, 392, 349.2, 329.6, 349.2,
+                    392, 440, 392, 349.2, 329.6, 349.2, 392, 659.3, 659.3, 659.3, 587.3, 587.3, 523.3, 523.3, 392,
+                    349.2, 329.6, 349.2, 392, 440, 493.9, 493.9, 587.3, 523.3, 493.9, 493.9, 493.9, 440, 493.9,
+                    493.9, 523.3, 587.3, 493.9, 587.3, 587.3, 587.3, 587.3, 587.3, 523.3, 493.9, 440, 392, 659.3,
+                    659.3, 659.3, 587.3, 587.3, 523.3, 523.3, 392, 349.2, 329.6, 349.2, 392, 440, 493.9, 493.9,
+                    587.3, 523.3, 0
+                   };
+//trajanje nota
+float beat[]= {1, 1, 1.5, 0.5, 0.5, 0.5, 1, 2, 0.5, 0.5, 0.5, 0.5, 2, 0.5, 0.5, 0.5, 0.5, 2, 1, 1, 1.5, 0.5,
+               0.5, 0.5, 1, 2, 0.5, 0.5, 0.5, 0.5, 2, 0.5, 0.5, 1, 2, 1, 1, 1.5, 0.5, 1, 0.5, 0.5, 1.5, 0.5, 0.5, 0.5, 0.5,
+               0.5, 1, 1, 1, 1, 2, 1, 1, 1.5, 0.5, 0.5, 0.5, 1, 2, 0.5, 0.5, 0.5, 0.5, 2, 0.5, 0.5, 1, 2, 0.5
+              };
+int main()
+{
+    while (1) {
+        for (int i=0; i<=70; i++) {
+            buzzer.period(1/(frequency[i])); // set PWM period
+            buzzer=0.5; // set duty cycle
+            wait(0.5*beat[i]); // hold for beat period
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Dec 10 17:58:35 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/165afa46840b
\ No newline at end of file