![](/media/cache/profiles/2012_sf_avc_095.jpg.50x50_q85.jpg)
Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.
Dependencies: Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo
Diff: UI/Beep/Beep.cpp
- Revision:
- 0:826c6171fc1b
diff -r 000000000000 -r 826c6171fc1b UI/Beep/Beep.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/UI/Beep/Beep.cpp Wed Jun 20 14:57:48 2012 +0000 @@ -0,0 +1,33 @@ +#include "mbed.h" +#include "Beep.h" + +/** Create a Beep object connected to the specified PwmOut pin + * + * @param pin PwmOut pin to connect to + */ +Beep::Beep(PinName pin) : _pwm(pin) { + _pwm.write(0.0); // after creating it have to be off +} + + /** Stop the beep instantaneously. + */ +void Beep::nobeep() { + _pwm.write(0.0); +} + +/** 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::beep(float freq, float time) { + + _pwm.period(1.0/freq); + _pwm.write(0.5); // 50% duty cycle - beep on + toff.attach(this,&Beep::nobeep, time); // time to off +} + + + +