play sounds with a buzzer
Dependencies: mbed
Revision 1:1eefeb256849, committed 2016-05-12
- Comitter:
- maclobdell
- Date:
- Thu May 12 17:34:03 2016 +0000
- Parent:
- 0:586507ee54a5
- 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 586507ee54a5 -r 1eefeb256849 main.cpp --- 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