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

Committer:
shimniok
Date:
Fri Nov 30 16:11:53 2018 +0000
Revision:
25:bb5356402687
Parent:
0:a6a169de725f
Initial publish of revised version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 0:a6a169de725f 1 #ifndef MBED_BEEP_H
shimniok 0:a6a169de725f 2 #define MBED_BEEP_H
shimniok 0:a6a169de725f 3
shimniok 0:a6a169de725f 4 #include "mbed.h"
shimniok 0:a6a169de725f 5
shimniok 0:a6a169de725f 6 /** Generates a tone with a buzzer, based on a PwmOut
shimniok 0:a6a169de725f 7 * The class use a timeout to switch off the sound - it is not blocking while making noise
shimniok 0:a6a169de725f 8 *
shimniok 0:a6a169de725f 9 * Example:
shimniok 0:a6a169de725f 10 * @code
shimniok 0:a6a169de725f 11 * // Beep at 2kHz for 0.5 seconds
shimniok 0:a6a169de725f 12 * #include "mbed.h"
shimniok 0:a6a169de725f 13 * #include "Beep.h"
shimniok 0:a6a169de725f 14 *
shimniok 0:a6a169de725f 15 * Beep buzzer(p21);
shimniok 0:a6a169de725f 16 *
shimniok 0:a6a169de725f 17 * int main() {
shimniok 0:a6a169de725f 18 * ...
shimniok 0:a6a169de725f 19 * buzzer.beep(2000,0.5);
shimniok 0:a6a169de725f 20 * ...
shimniok 0:a6a169de725f 21 * }
shimniok 0:a6a169de725f 22 * @endcode
shimniok 0:a6a169de725f 23 */
shimniok 0:a6a169de725f 24 class Beep {
shimniok 0:a6a169de725f 25
shimniok 0:a6a169de725f 26 public:
shimniok 0:a6a169de725f 27
shimniok 0:a6a169de725f 28 /** Create a Beep object connected to the specified PwmOut pin
shimniok 0:a6a169de725f 29 *
shimniok 0:a6a169de725f 30 * @param pin PwmOut pin to connect to
shimniok 0:a6a169de725f 31 */
shimniok 0:a6a169de725f 32 Beep(PinName pin);
shimniok 0:a6a169de725f 33
shimniok 0:a6a169de725f 34 /** Beep with given frequency and duration.
shimniok 0:a6a169de725f 35 *
shimniok 0:a6a169de725f 36 * @param frequency - the frequency of the tone in Hz
shimniok 0:a6a169de725f 37 * @param time - the duration of the tone in seconds
shimniok 0:a6a169de725f 38 */
shimniok 0:a6a169de725f 39 void beep(float frequency, float time);
shimniok 0:a6a169de725f 40
shimniok 0:a6a169de725f 41 /** stop the beep instantaneously. Not typically needed, but here just in case
shimniok 0:a6a169de725f 42 */
shimniok 0:a6a169de725f 43 void nobeep();
shimniok 0:a6a169de725f 44
shimniok 0:a6a169de725f 45 private :
shimniok 0:a6a169de725f 46 PwmOut _pwm;
shimniok 0:a6a169de725f 47 Timeout toff;
shimniok 0:a6a169de725f 48 };
shimniok 0:a6a169de725f 49 #endif