Part One of my Project Course. Implementation of simple I/O and a custom defined protocol over UDP/IP.
Dependencies: C12832 LM75B mbed EthernetInterface mbed-rtos
Diff: buzzer_music.cpp
- Revision:
- 0:88d3b9015f7c
- Child:
- 1:b5c534165dfe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/buzzer_music.cpp Mon Feb 26 11:25:59 2018 +0000 @@ -0,0 +1,28 @@ +#include "buzzer_music.h" +#include "master.h" + +namespace ProjectOne{ + + const int BuzzerMusic::frequencies[] = {110,110,110,98,130,110,98,130,110,165,165,165,175,130,104,98,130}; + const int BuzzerMusic::lengths[] = {480,480,480,360,120,480,360,120,960,480,480,480,360,120,480,360,120}; + const int BuzzerMusic::delays[] = {100,100,100,75,100,100,75,100,100,100,100,100,75,100,100,75,100}; + + //PwmOut speaker(NC); + + BuzzerMusic::BuzzerMusic(PinName speakerPin) : speaker(speakerPin){ + + } + + void BuzzerMusic::playMusic(int x, int y){ + for(int i = x; i < y; i ++){ + speaker = 0.5; + speaker.period(1.0/frequencies[i]); + wait((float)lengths[i]/1000); + speaker = 0.0; + wait((float)delays[i]/1000); + } + printf("Played Music"); + } + +} +