Generate Morse code using console text input and output to LED and speaker.
Dependencies: 4DGL-uLCD-SE PinDetect mbed
Speaker.h
00001 #include "mbed.h" 00002 // new class to play a note on Speaker based on PwmOut class 00003 class Speaker 00004 { 00005 public: 00006 Speaker(PinName pin) : _pin(pin) 00007 { 00008 // _pin(pin) means pass pin to the Speaker Constructor 00009 } 00010 00011 // class method to play a note based on PwmOut class 00012 void PlayNote(float frequency, float duration, float volume) 00013 { 00014 _pin.period(1.0/frequency); // higher number = more base 00015 _pin = volume/2.0; // higher number = more weird treble 00016 wait(duration); 00017 _pin = 0.0; 00018 } 00019 00020 private: 00021 PwmOut _pin; 00022 };
Generated on Fri Jul 15 2022 21:19:08 by 1.7.2