use an accelerometer to generate sounds

Dependencies:   FXOS8700CQ mbed

Files at this revision

API Documentation at this revision

Comitter:
maclobdell
Date:
Thu May 12 17:34:47 2016 +0000
Parent:
1:c3cb527a2aa6
Commit message:
fixed play tone function to not set frequency as the period

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r c3cb527a2aa6 -r cc285ff20aac main.cpp
--- a/main.cpp	Tue May 10 16:48:32 2016 +0000
+++ b/main.cpp	Thu May 12 17:34:47 2016 +0000
@@ -20,7 +20,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) {
-    buzzer.period_us(tone);
+    buzzer.period_us(1000000/(tone));
     buzzer.write(0.10f); // 10% duty cycle, otherwise it's too loud
 }