oki

Dependencies:   mbed

Fork of ProjetInfo2_Multi by julien bitoun

music.h

Committer:
thomasstrcic
Date:
2018-06-12
Revision:
4:23e955d622f9
Parent:
2:ae058dfdebac

File content as of revision 4:23e955d622f9:

// Oranges and Lemons program 
#include "mbed.h" 
PwmOut HP(p21); 
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() {  
    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;
}