![](/media/cache/group/headphones.png.50x50_q85.jpg)
use an accelerometer to generate sounds
Dependencies: FXOS8700CQ mbed
Diff: main.cpp
- Revision:
- 2:cc285ff20aac
- Parent:
- 1:c3cb527a2aa6
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 }