oki

Dependencies:   mbed

Fork of ProjetInfo2_Multi by julien bitoun

music.h

Committer:
thomasstrcic
Date:
2018-06-01
Revision:
2:ae058dfdebac
Parent:
1:d446f0124474
Child:
3:98f5de1dd010

File content as of revision 2:ae058dfdebac:

// 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() {  
    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;
}