Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: 4DGL-uLCD-SE PinDetect mbed SparkfunAnalogJoystick mbed-rtos
Fork of ECE2036Lab2StarterCode by
Speaker.h
00001 #include "mbed.h" 00002 // new class to play a note on Speaker based on PwmOut class 00003 #ifndef _SPEAKER_H 00004 #define _SPEAKER_H 00005 class Speaker 00006 { 00007 public: 00008 Speaker(PinName pin) : _pin(pin) { 00009 // _pin(pin) means pass pin to the Speaker Constructor 00010 } 00011 // class method to play a note based on PwmOut class 00012 void PlayNote(float frequency, float duration, float volume) { 00013 _pin.period(1.0/frequency); 00014 _pin = volume/2.0; 00015 wait(duration); 00016 _pin = 0.0; 00017 } 00018 00019 private: 00020 PwmOut _pin; 00021 }; 00022 00023 #endif // _SPEAKER_H
Generated on Fri Jul 15 2022 08:13:00 by
