Projectlab Elektronica-ICT KULeuven

Dependencies:   EthernetInterface TMP102 TextLCD mbed-rtos mbed

werking.pdf

Committer:
seppeduwe
Date:
Mon Mar 17 18:40:46 2014 +0000
Revision:
4:466d859bfb13
Parent:
0:ae3af7d18c4a
Einde Labo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
seppeduwe 0:ae3af7d18c4a 1 #include "Tune.h"
seppeduwe 0:ae3af7d18c4a 2 const int Tune::freq[] = {660,660,660,510,660,770,380,510,380,320,440,480,450,430,380};
seppeduwe 0:ae3af7d18c4a 3 const int Tune::lenght[] = {100,100,100,100,100,100,100,100,100,100,100,80, 100,100,100};
seppeduwe 0:ae3af7d18c4a 4 const int Tune::delay[] = {150,300,300,100,300,550,575,450,400,500,300,330,150,300,200};
seppeduwe 0:ae3af7d18c4a 5 Tune::Tune()
seppeduwe 0:ae3af7d18c4a 6 {
seppeduwe 0:ae3af7d18c4a 7 speaker=new PwmOut(p21);
seppeduwe 0:ae3af7d18c4a 8 }
seppeduwe 0:ae3af7d18c4a 9 void Tune::play(int tune)
seppeduwe 0:ae3af7d18c4a 10 {
seppeduwe 0:ae3af7d18c4a 11 speaker->period(1.0/(freq[tune-1]));
seppeduwe 0:ae3af7d18c4a 12 speaker->write(0.5); //Set duty cycle to 50%
seppeduwe 0:ae3af7d18c4a 13
seppeduwe 0:ae3af7d18c4a 14 wait_ms(lenght[tune-1]);
seppeduwe 0:ae3af7d18c4a 15 speaker->write(0.0); //Set duty cycle to 50%
seppeduwe 0:ae3af7d18c4a 16
seppeduwe 0:ae3af7d18c4a 17 wait_ms(delay[tune-1]);
seppeduwe 0:ae3af7d18c4a 18 }