![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
Code for autonomous rover for Sparkfun AVC. DataBus won 3rd in 2012 and the same code was used on Troubled Child, a 1986 Jeep Grand Wagoneer to win 1st in 2014.
Dependencies: mbed Watchdog SDFileSystem DigoleSerialDisp
Diff: UI/Beep/Beep.h
- Revision:
- 0:a6a169de725f
diff -r 000000000000 -r a6a169de725f UI/Beep/Beep.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/Beep/Beep.h Mon May 27 13:26:03 2013 +0000 @@ -0,0 +1,49 @@ +#ifndef MBED_BEEP_H +#define MBED_BEEP_H + +#include "mbed.h" + +/** Generates a tone with a buzzer, based on a PwmOut + * The class use a timeout to switch off the sound - it is not blocking while making noise + * + * Example: + * @code + * // Beep at 2kHz for 0.5 seconds + * #include "mbed.h" + * #include "Beep.h" + * + * Beep buzzer(p21); + * + * int main() { + * ... + * buzzer.beep(2000,0.5); + * ... + * } + * @endcode + */ +class Beep { + +public: + +/** Create a Beep object connected to the specified PwmOut pin + * + * @param pin PwmOut pin to connect to + */ + Beep(PinName pin); + +/** Beep with given frequency and duration. + * + * @param frequency - the frequency of the tone in Hz + * @param time - the duration of the tone in seconds + */ + void beep(float frequency, float time); + +/** stop the beep instantaneously. Not typically needed, but here just in case + */ + void nobeep(); + +private : + PwmOut _pwm; + Timeout toff; +}; +#endif