thomas strcic
/
ProjetInfo2_Multi12
oki
Fork of ProjetInfo2_Multi by
Diff: music.h
- Revision:
- 1:d446f0124474
- Child:
- 2:ae058dfdebac
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/music.h Tue May 22 11:51:24 2018 +0000 @@ -0,0 +1,21 @@ +// Oranges and Lemons program +#include "mbed.h" +PwmOut HP(p23); +void music (void); +int y=0; +float frequence[]={659,554,659,554,550,494,554,587, +494,659,554,440}; + //frequency array +float beat[]={1,1,1,1,1,0.5,0.5,1,1,1,1,2}; //beat array +void music() { + while (y<1) { + for (int i=0; i<=11; i++) { + HP.period(1/(frequence[i])); // set PWM period + HP.write(0.5); // set duty cycle + wait(0.5*beat[i]); // hold for beat period + y++; + } + } + HP.period(0); + y=0; +}