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: mbed
main.cpp
- Committer:
 - 4180_1
 - Date:
 - 2014-10-21
 - Revision:
 - 2:68eee0fb2026
 - Parent:
 - 0:b2fdf3770282
 - Child:
 - 3:61d42134c1be
 
File content as of revision 2:68eee0fb2026:
#include "mbed.h"
#include "Speaker.h"
// Speaker test program - euro police style siren now using new Speaker class method
// for documentation see http://mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/
// can also be used to play a song, if you have all of the notes and durations
// for musical note frequencies see http://en.wikipedia.org/wiki/Piano_key_frequencies
int main()
{
// setup instance of new Speaker class, mySpeaker using pin 21
// the pin must be a PWM output pin
    Speaker mySpeaker(p21);
    // loops forever playing two notes on speaker
    while(1) {
        mySpeaker.PlayNote(969.0,0.5,0.5);
        mySpeaker.PlayNote(800.0,0.5,0.5);
    }
}