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.
main.cpp
- Committer:
- suupen
- Date:
- 2011-11-20
- Revision:
- 0:0b399d7dc98a
File content as of revision 0:0b399d7dc98a:
//=============================================
// Sound Library Example Program
// This sample program will play a single note
//
// <schematic>
//
// /
// mbed -------------- --/
// p21(pwmOut) -----| R:200[ohm] |-----| | speaker
// -------------- | |
// | |
// p10(DigitalOut) ------------------------| |
// --\
// \
//==============================================
#include "mbed.h"
#include "Sound.h"
Sound sound(p21, p10);
int main() {
while(1) {
// tone1 (G5 Pronunciation time = 200ms, envelope time = 100ms)
Sound::sound_t oto = {1,0x95,200,100};
sound.sound_sound(oto); // To start the sound output
while(sound.sound_sound() == true){} // Wait until the end of the sound output
// tone2 (A5 Pronunciation time = 2000ms, envelope time = 1000ms)
oto.hanon = 1; oto.onkai = 0xA5; oto.time = 2000; oto.envelope = 1000;
sound.sound_sound(oto);
while(sound.sound_sound() == true){}
}
}