このサンプルプログラムはメロディを演奏するプログラムです。 mbed driveに\"enso.txt\"として保管したメロディデータを演奏します。 This sample program is a program that plays the melody. The mbed drive \"enso.txt\" data stored as the melody. =video= {{http://www.youtube.com/watch?v=rYifJsrIPwo}} =メロディデータファイル (melody data file) = 下記のデータを"enso.txt"のFileNameでmbedのdriveに保管してください。 (メロディはウエストミンスターのチャイム(学校のチャイム)です) [[/media/uploads/suupen/enso.txt]] <<code>> 0xA4 1200 1000 0xF4 1200 1000 0x94 1200 1000 0xC4 2400 1000 0xC4 1200 1000 0x94 1200 1000 0xA4 1200 1000 0xF4 2400 1000 0xA4 1200 1000 0xF4 1200 1000 0x94 1200 1000 0xC4 2400 1000 0xC4 1200 1000 0x94 1200 1000 0xA4 1200 1000 0xF4 2400 1000 0xFF 1000 0 <</code>>

Dependencies:   mbed

Committer:
suupen
Date:
Sun Nov 20 10:05:23 2011 +0000
Revision:
0:1a3b7e3ad665
V1.0   2011/11/20

Who changed what in which revision?

UserRevisionLine numberNew contents of line
suupen 0:1a3b7e3ad665 1 //=============================================
suupen 0:1a3b7e3ad665 2 // Sound Library Example Program
suupen 0:1a3b7e3ad665 3 // This sample program will play a melody
suupen 0:1a3b7e3ad665 4 // mbed drive to get the data from the melody
suupen 0:1a3b7e3ad665 5 //
suupen 0:1a3b7e3ad665 6 // <schematic>
suupen 0:1a3b7e3ad665 7 //
suupen 0:1a3b7e3ad665 8 // /
suupen 0:1a3b7e3ad665 9 // mbed -------------- --/
suupen 0:1a3b7e3ad665 10 // p21(pwmOut) -----| R:200[ohm] |-----| | speaker
suupen 0:1a3b7e3ad665 11 // -------------- | |
suupen 0:1a3b7e3ad665 12 // | |
suupen 0:1a3b7e3ad665 13 // p10(DigitalOut) ------------------------| |
suupen 0:1a3b7e3ad665 14 // --\
suupen 0:1a3b7e3ad665 15 // \
suupen 0:1a3b7e3ad665 16 //==============================================
suupen 0:1a3b7e3ad665 17 #include "mbed.h"
suupen 0:1a3b7e3ad665 18 #include "Sound.h"
suupen 0:1a3b7e3ad665 19
suupen 0:1a3b7e3ad665 20
suupen 0:1a3b7e3ad665 21 Sound sound(p21, p10); // p21(PwmOut), p10(DigitalOut)
suupen 0:1a3b7e3ad665 22
suupen 0:1a3b7e3ad665 23 int main() {
suupen 0:1a3b7e3ad665 24
suupen 0:1a3b7e3ad665 25 // mbed drive to get the data from the melody
suupen 0:1a3b7e3ad665 26 sound.sound_enso("/local/enso.txt");
suupen 0:1a3b7e3ad665 27 while(1) {
suupen 0:1a3b7e3ad665 28 if(sound.sound_enso() == false){
suupen 0:1a3b7e3ad665 29 sound.sound_enso(true);
suupen 0:1a3b7e3ad665 30 }
suupen 0:1a3b7e3ad665 31
suupen 0:1a3b7e3ad665 32 }
suupen 0:1a3b7e3ad665 33 }