Gopal Nair
/
Arch_Play_Music
Use a buzz (piezo) to produce music
Fork of Arch_Play_Music by
Revision 1:980e7d018900, committed 2017-07-06
- Comitter:
- naray23
- Date:
- Thu Jul 06 15:40:29 2017 +0000
- Parent:
- 0:343592047b5a
- Commit message:
- None
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 343592047b5a -r 980e7d018900 main.cpp --- a/main.cpp Mon Apr 28 06:13:29 2014 +0000 +++ b/main.cpp Thu Jul 06 15:40:29 2017 +0000 @@ -3,15 +3,18 @@ DigitalOut myled(LED1); -PwmOut buzzer(P1_14); +PwmOut buzzer(PTD4); -int frequency[] = {NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3, 1, NOTE_B3, NOTE_C4}; -int beat[] = {4, 8, 8, 4,4,4,4,4 }; +//int frequency[] = {NOTE_C4, NOTE_G3,NOTE_G3, NOTE_A3, NOTE_G3, 1, NOTE_B3, NOTE_C4}; +//int beat[] = {4, 8, 8, 4,4,4,4,4 }; + +int frequency[] = {NOTE_C5, NOTE_B4,NOTE_G4, NOTE_C5, NOTE_B4,NOTE_E4, 1.0, NOTE_C5,NOTE_C4,NOTE_G4,NOTE_A4,NOTE_C5}; +int beat[] = {16, 16, 16, 8, 8, 16, 32, 16, 16, 16, 8, 8 }; int main() { for (int i = 0; i < (sizeof(frequency) / sizeof(int)); i++) { - buzzer.period(1.0 / frequency[i]); - buzzer.write(0.5); + buzzer.period(1.0 / frequency[i]);//set period + buzzer.write(0.5);//set duty cycle wait(1.0 / beat[i]); buzzer.write(0); wait(0.05);