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.
Dependencies: MIDISongPlayer mbed
main.cpp
00001 #include "mbed.h" 00002 #include "SongPlayer.h" 00003 #include "sound.h" // test sound 00004 00005 // Song test program - plays a MIDI song using PWM and timer interrupts 00006 // based on http://mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/ 00007 // can be used to play a song, if you have the MIDI notes sequence 00008 00009 00010 00011 00012 DigitalOut led1(LED1); 00013 00014 int main() 00015 { 00016 00017 // setup instance of new SongPlayer class, mySpeaker using pin D9 00018 // the pin must be a PWM output pin 00019 SongPlayer mySpeaker(D9); 00020 // Start song and return once playing starts 00021 mySpeaker.PlaySong(score3); 00022 // loops forever while song continues to play to end using interrupts 00023 int cnt=0; 00024 while(1) { 00025 led1 = !led1; 00026 wait(.1); 00027 cnt++; 00028 if (cnt>100) mySpeaker.StopPlay(); // play 10 second, then stop 00029 } 00030 }
Generated on Fri Jul 22 2022 13:50:42 by
1.7.2