Code for autonomous ground vehicle, Data Bus, 3rd place winner in 2012 Sparkfun AVC.

Dependencies:   Watchdog mbed Schedule SimpleFilter LSM303DLM PinDetect DebounceIn Servo

Embed: (wiki syntax)

« Back to documentation index

Beep Class Reference

Beep Class Reference

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. More...

#include <Beep.h>

Public Member Functions

 Beep (PinName pin)
 Create a Beep object connected to the specified PwmOut pin.
void beep (float frequency, float time)
 Beep with given frequency and duration.
void nobeep ()
 stop the beep instantaneously.

Detailed Description

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:

 // Beep at 2kHz for 0.5 seconds
 #include "mbed.h"
 #include "Beep.h"
 
 Beep buzzer(p21);
 
 int main() {
        ...
   buzzer.beep(2000,0.5);    
       ...
 }

Definition at line 24 of file Beep.h.


Constructor & Destructor Documentation

Beep ( PinName  pin )

Create a Beep object connected to the specified PwmOut pin.

Parameters:
pinPwmOut pin to connect to

Definition at line 8 of file Beep.cpp.


Member Function Documentation

void beep ( float  freq,
float  time 
)

Beep with given frequency and duration.

Parameters:
frequency- the frequency of the tone in Hz
time- the duration of the tone in seconds

Definition at line 24 of file Beep.cpp.

void nobeep (  )

stop the beep instantaneously.

Stop the beep instantaneously.

Not typically needed, but here just in case

Definition at line 14 of file Beep.cpp.