Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of blip_playnotes by
Diff: main.cpp
- Revision:
- 2:85d8ce475baa
- Parent:
- 1:2e6ea42675c7
- Child:
- 3:a6355b9de221
--- a/main.cpp Tue Oct 21 03:00:15 2014 +0000 +++ b/main.cpp Thu Nov 26 09:28:03 2015 +0000 @@ -1,11 +1,9 @@ +// miniblip play notes with interrupts - Not tested with led matrix +// For documentation see http://mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/ + #include "mbed.h" #include "SongPlayer.h" -// Song test program - plays a song using PWM and timer interrupts -// for documentation see http://mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/ -// can be used to play a song, if you have the notes and durations -// for musical note frequencies see http://en.wikipedia.org/wiki/Piano_key_frequencies - //Set up notes and durations for sample song to play // A 0.0 duration note at end terminates song play float note[18]= {1568.0,1396.9,1244.5,1244.5,1396.9,1568.0,1568.0,1568.0,1396.9, @@ -15,17 +13,14 @@ 0.24,0.24,0.24,0.24,0.48,0.24,0.48,0.48, 0.0 }; -DigitalOut led1(LED1); int main() { -// setup instance of new SongPlayer class, mySpeaker using pin 26 -// the pin must be a PWM output pin - SongPlayer mySpeaker(p26); -// Start song and return once playing starts + // Buzzer pin + SongPlayer mySpeaker(P0_8); + // Start song and return once playing starts mySpeaker.PlaySong(note,duration); // loops forever while song continues to play to end using interrupts while(1) { - led1 = !led1; wait(.1); } }