play sounds with a buzzer

Dependencies:   mbed

Revision:
1:1eefeb256849
Parent:
0:586507ee54a5
--- a/main.cpp	Mon May 09 19:50:27 2016 +0000
+++ b/main.cpp	Thu May 12 17:34:03 2016 +0000
@@ -15,7 +15,7 @@
 // this is our function that plays a tone. 
 // Takes in a tone frequency, and after duration (in ms.) we stop playing again
 static void play_tone(int tone, int duration) {
-    buzzer.period_us(tone);
+    buzzer.period_us(1000000/(tone));
     buzzer.write(0.10f); // 10% duty cycle, otherwise it's too loud
     
     // we wait for duration ms. and then call the silence function