oki

Dependencies:   mbed

Fork of ProjetInfo2_Multi by julien bitoun

Committer:
thomasstrcic
Date:
Tue Jun 05 11:54:56 2018 +0000
Revision:
3:98f5de1dd010
Parent:
2:ae058dfdebac
nique bitoun

Who changed what in which revision?

UserRevisionLine numberNew contents of line
thomasstrcic 1:d446f0124474 1 // Oranges and Lemons program
thomasstrcic 1:d446f0124474 2 #include "mbed.h"
thomasstrcic 3:98f5de1dd010 3 PwmOut HP(p21);
thomasstrcic 1:d446f0124474 4 void music (void);
thomasstrcic 1:d446f0124474 5 int y=0;
thomasstrcic 1:d446f0124474 6 float frequence[]={659,554,659,554,550,494,554,587,
thomasstrcic 1:d446f0124474 7 494,659,554,440};
thomasstrcic 1:d446f0124474 8 //frequency array
thomasstrcic 1:d446f0124474 9 float beat[]={1,1,1,1,1,0.5,0.5,1,1,1,1,2}; //beat array
thomasstrcic 2:ae058dfdebac 10 void music() {
thomasstrcic 1:d446f0124474 11 for (int i=0; i<=11; i++) {
thomasstrcic 1:d446f0124474 12 HP.period(1/(frequence[i])); // set PWM period
thomasstrcic 1:d446f0124474 13 HP.write(0.5); // set duty cycle
thomasstrcic 1:d446f0124474 14 wait(0.5*beat[i]); // hold for beat period
thomasstrcic 1:d446f0124474 15 y++;
thomasstrcic 1:d446f0124474 16 }
thomasstrcic 1:d446f0124474 17 HP.period(0);
thomasstrcic 1:d446f0124474 18 y=0;
thomasstrcic 1:d446f0124474 19 }