Himna

Dependencies:   mbed

Fork of fistrek_intenzitetdiode by Applied engineering Team

Files at this revision

API Documentation at this revision

Comitter:
ffistrek
Date:
Thu Dec 10 17:58:18 2015 +0000
Parent:
5:3dcf87833bbb
Commit message:
Fistrek_lijepa nasa

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 3dcf87833bbb -r 85455665f4d5 main.cpp
--- a/main.cpp	Thu Dec 10 17:42:33 2015 +0000
+++ b/main.cpp	Thu Dec 10 17:58:18 2015 +0000
@@ -1,28 +1,20 @@
-// host terminal LED dimmer control
 #include "mbed.h"
-Serial pc(USBTX, USBRX); // tx, rx
-PwmOut PWM1(p21);
-float brightness=0.0;
+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() {
-PWM1.period(0.010); // set PWM period to 10 ms
-PWM1=0.8; // set duty cycle to 80%
-pc.printf("Control of LED dimmer by host terminal\n\r");
-pc.printf("Press 'u' = brighter, 'd' = dimmer\n\r");
-while(1) {
-char c = pc.getc();
-wait(0.001);
-if((c == 'u') && (brightness < 1.0)) {
-brightness += 0.1;
-PWM1= brightness;
-}
-if((c == 'd') && (brightness > 0.0)) {
-brightness -= 0.1;
-PWM1= brightness;
-}
-if(c == 'x'){
-brightness = 0.5;
-PWM1 = brightness;
-}    
-pc.printf("%c %1.3f \n \r",c,brightness);
-}
-}
+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
+} } }
\ No newline at end of file