Encoding messsages, continuously written on serial terminal, in Morse code. Resulting code is played by a buzzer. Please, use local echo on terminal for more impressive experience. To verify coded messages, there are some app for smartphone.
Fork of Morse by
Speaker.h
- Committer:
- marcoperciavalle
- Date:
- 2018-02-03
- Revision:
- 2:39d67345f7b3
File content as of revision 2:39d67345f7b3:
#include "mbed.h" // new class to play a note on Speaker based on PwmOut class class Speaker { public: Speaker(PinName pin) : _pin(pin) { // _pin(pin) means pass pin to the Speaker Constructor } // class method to play a note based on PwmOut class void PlayNote(float frequency, float duration, float volume) { _pin.period(1.0/frequency); // higher number = more base _pin = volume/2.0; // higher number = more weird treble wait(duration); _pin = 0.0; } private: PwmOut _pin; };