Real Time Lab Program

Dependencies:   mbed

main.cpp

Committer:
robt
Date:
2015-01-25
Revision:
0:4463987cbbfb

File content as of revision 0:4463987cbbfb:

#include "mbed.h"
PwmOut buzzer(p25);

//frequency array
float frequency[]= {659,554,659,554,440,494,554,587,494,659,554,440};
//beat array
float beat[]= {1,1,1,1,1,0.5,0.5,1,1,1,1,2};   


          
int main()
{
    while (1) {
        for (int i=0; i<=11; i++) {
            buzzer.period(1/(frequency[i]));               // set PWM period
            buzzer=0.5;                                    // set duty cycle
            wait(beat[i]);                                 // hold for beat period
        }
    }
}