Projectlab Elektronica-ICT KULeuven

Dependencies:   EthernetInterface TMP102 TextLCD mbed-rtos mbed

werking.pdf

Revision:
0:ae3af7d18c4a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Tune.cpp	Fri Mar 14 19:41:14 2014 +0000
@@ -0,0 +1,18 @@
+#include "Tune.h"
+const int Tune::freq[]   = {660,660,660,510,660,770,380,510,380,320,440,480,450,430,380};
+const int Tune::lenght[] = {100,100,100,100,100,100,100,100,100,100,100,80, 100,100,100};
+const int Tune::delay[]  = {150,300,300,100,300,550,575,450,400,500,300,330,150,300,200};
+Tune::Tune()
+{
+    speaker=new PwmOut(p21);
+}
+void Tune::play(int tune)
+{
+    speaker->period(1.0/(freq[tune-1]));
+    speaker->write(0.5); //Set duty cycle to 50%
+
+    wait_ms(lenght[tune-1]);
+    speaker->write(0.0); //Set duty cycle to 50%
+
+    wait_ms(delay[tune-1]);
+}
\ No newline at end of file