Clock

Dependencies:   4DGL-uLCD-SE EthernetInterface NTPClient TextLCD mbed PinDetect SDFileSystem wave_player mbed-rtos

Fork of Internet_LCD_Clock by jim hamblen

Committer:
ashea6
Date:
Wed Apr 20 20:28:20 2016 +0000
Revision:
5:818735a07b88
wave error

Who changed what in which revision?

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