Alberto Piganti / Mbed 2 deprecated blip_playnotes

Dependencies:   mbed

Fork of song_demo_PWM by jim hamblen

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // miniblip play notes with interrupts - Not tested with led matrix
00002 // For documentation see http://mbed.org/users/4180_1/notebook/using-a-speaker-for-audio-output/
00003 
00004 #include "mbed.h"
00005 #include "SongPlayer.h"
00006 
00007 //Set up notes and durations for sample song to play
00008 // A 0.0 duration note at end terminates song play
00009 float note[18]= {1568.0,1396.9,1244.5,1244.5,1396.9,1568.0,1568.0,1568.0,1396.9,
00010                  1244.5,1396.9,1568.0,1396.9,1244.5,1174.7,1244.5,1244.5, 0.0
00011                 };
00012 float duration[18]= {0.48,0.24,0.72,0.48,0.24,0.48,0.24,0.24,0.24,
00013                      0.24,0.24,0.24,0.24,0.48,0.24,0.48,0.48, 0.0
00014                     };
00015 
00016 int main()
00017 {
00018     // Buzzer pin
00019     SongPlayer mySpeaker(P0_8);
00020     // Start song and return once playing starts
00021     mySpeaker.PlaySong(note,duration);
00022     // loops forever while song continues to play to end using interrupts
00023     while(1) {
00024         wait(.1);
00025     }
00026 }
00027