Projectlab Elektronica-ICT KULeuven

Dependencies:   EthernetInterface TMP102 TextLCD mbed-rtos mbed

werking.pdf

Tune.cpp

Committer:
seppeduwe
Date:
2014-03-17
Revision:
4:466d859bfb13
Parent:
0:ae3af7d18c4a

File content as of revision 4:466d859bfb13:

#include "Tune.h"
const int Tune::freq[]   = {660,660,660,510,660,770,380,510,380,320,440,480,450,430,380};
const int Tune::lenght[] = {100,100,100,100,100,100,100,100,100,100,100,80, 100,100,100};
const int Tune::delay[]  = {150,300,300,100,300,550,575,450,400,500,300,330,150,300,200};
Tune::Tune()
{
    speaker=new PwmOut(p21);
}
void Tune::play(int tune)
{
    speaker->period(1.0/(freq[tune-1]));
    speaker->write(0.5); //Set duty cycle to 50%

    wait_ms(lenght[tune-1]);
    speaker->write(0.0); //Set duty cycle to 50%

    wait_ms(delay[tune-1]);
}