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.
Dependents: acd52832_beep_buzzer
Fork of beep by
beep.h
00001 #ifndef MBED_BEEP_H 00002 #define MBED_BEEP_H 00003 00004 #include "mbed.h" 00005 00006 #define isdigit(n) (n >= '0' && n <= '9') 00007 #define OCTAVE_OFFSET 0 00008 00009 /** class to make sound with a buzzer, based on a PwmOut 00010 * The class use a timeout to switch off the sound - it is not blocking while making noise 00011 * 00012 * Example: 00013 * @code 00014 * // Beep with 1Khz for 0.5 seconds 00015 * #include "mbed.h" 00016 * #include "beep.h" 00017 * 00018 * Beep buzzer(p21); 00019 * 00020 * int main() { 00021 * ... 00022 * buzzer.beep(1000,0.5); 00023 * ... 00024 * } 00025 * @endcode 00026 */ 00027 00028 00029 namespace mbed { 00030 00031 /* Class: Beep 00032 * A class witch uses pwm to controle a beeper to generate sounds. 00033 */ 00034 class Beep { 00035 00036 public: 00037 00038 /** Create a Beep object connected to the specified PwmOut pin 00039 * 00040 * @param pin PwmOut pin to connect to 00041 */ 00042 Beep (PinName pin); 00043 00044 /** Beep with given frequency and duration. 00045 * 00046 * @param frequency - the frequency of the tone in Hz 00047 * @param time - the duration of the tone in seconds 00048 */ 00049 void beep (float frequency, float time); 00050 void playRttl(char *p); 00051 00052 /** stop the beep instantaneous 00053 * usually not used 00054 */ 00055 void nobeep(); 00056 00057 private : 00058 PwmOut _pwm; 00059 Timeout toff; 00060 }; 00061 00062 } 00063 #endif
Generated on Fri Jul 15 2022 02:57:29 by
1.7.2
