ethernet for mbed2

Dependencies:   IoTsecuritySys mbed-rtos mbed

Committer:
jsmith352
Date:
Tue Dec 08 23:27:29 2015 +0000
Revision:
0:009a138526c5
ethernet for mbed2

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jsmith352 0:009a138526c5 1 #include "mbed.h"
jsmith352 0:009a138526c5 2 // new class to play a note on Speaker based on PwmOut class
jsmith352 0:009a138526c5 3 #ifndef _SPEAKER_H
jsmith352 0:009a138526c5 4 #define _SPEAKER_H
jsmith352 0:009a138526c5 5 class Speaker
jsmith352 0:009a138526c5 6 {
jsmith352 0:009a138526c5 7 public:
jsmith352 0:009a138526c5 8 Speaker(PinName pin) : _pin(pin) {
jsmith352 0:009a138526c5 9 // _pin(pin) means pass pin to the Speaker Constructor
jsmith352 0:009a138526c5 10 }
jsmith352 0:009a138526c5 11 // class method to play a note based on PwmOut class
jsmith352 0:009a138526c5 12 void PlayNote(float frequency, float duration, float volume) {
jsmith352 0:009a138526c5 13 _pin.period(1.0/frequency);
jsmith352 0:009a138526c5 14 _pin = volume/2.0;
jsmith352 0:009a138526c5 15 wait(duration);
jsmith352 0:009a138526c5 16 _pin = 0.0;
jsmith352 0:009a138526c5 17 }
jsmith352 0:009a138526c5 18
jsmith352 0:009a138526c5 19 private:
jsmith352 0:009a138526c5 20 PwmOut _pin;
jsmith352 0:009a138526c5 21 };
jsmith352 0:009a138526c5 22
jsmith352 0:009a138526c5 23 #endif // _SPEAKER_H