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:
23:a34af501ea89
Initial publish of revised version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shimniok 0:a6a169de725f 1 #include "mbed.h"
shimniok 0:a6a169de725f 2 #include "Beep.h"
shimniok 0:a6a169de725f 3
shimniok 0:a6a169de725f 4 /** Create a Beep object connected to the specified PwmOut pin
shimniok 0:a6a169de725f 5 *
shimniok 0:a6a169de725f 6 * @param pin PwmOut pin to connect to
shimniok 0:a6a169de725f 7 */
shimniok 0:a6a169de725f 8 Beep::Beep(PinName pin) : _pwm(pin) {
shimniok 0:a6a169de725f 9 _pwm.write(0.0); // after creating it have to be off
shimniok 0:a6a169de725f 10 }
shimniok 0:a6a169de725f 11
shimniok 0:a6a169de725f 12 /** Stop the beep instantaneously.
shimniok 0:a6a169de725f 13 */
shimniok 0:a6a169de725f 14 void Beep::nobeep() {
shimniok 0:a6a169de725f 15 _pwm.write(0.0);
shimniok 0:a6a169de725f 16 }
shimniok 0:a6a169de725f 17
shimniok 0:a6a169de725f 18 /** Beep with given frequency and duration.
shimniok 0:a6a169de725f 19 *
shimniok 0:a6a169de725f 20 * @param frequency - the frequency of the tone in Hz
shimniok 0:a6a169de725f 21 * @param time - the duration of the tone in seconds
shimniok 0:a6a169de725f 22 */
shimniok 0:a6a169de725f 23
shimniok 0:a6a169de725f 24 void Beep::beep(float freq, float time) {
shimniok 0:a6a169de725f 25
shimniok 0:a6a169de725f 26 _pwm.period(1.0/freq);
shimniok 0:a6a169de725f 27 _pwm.write(0.5); // 50% duty cycle - beep on
shimniok 23:a34af501ea89 28 toff.attach(callback(this, &Beep::nobeep), time); // time to off
shimniok 0:a6a169de725f 29 }
shimniok 0:a6a169de725f 30
shimniok 0:a6a169de725f 31
shimniok 0:a6a169de725f 32
shimniok 0:a6a169de725f 33