Make noise with a piezo buzzer. Use a pwm pin.
Dependents: GliderFuncTest1 DropTest
Fork of beep by
Diff: beep.h
- Revision:
- 0:18e4a9c978ec
- Child:
- 1:ddccf0a4a414
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/beep.h Tue Feb 01 18:44:45 2011 +0000 @@ -0,0 +1,40 @@ +#ifndef MBED_BEEP_H +#define MBED_BEEP_H + +#include "mbed.h" + +namespace mbed { + +/* Class: Beep + * A class witch uses pwm to controle a beeper to generate sounds. + */ +class Beep { + +public: + + /* Constructor: Beep + * Creates a new beeper object. + * + * Variables: + * pin - The pin which is connected to the beeper. + */ + Beep (PinName pin); + + /* Function: beep + * Beep with given frequency and duration. + * + * Variables: + * frequency - The frequency to use. + * time - The turation to beep. + */ + void beep (float frequency, float time); + + void nobeep(); + +private : + PwmOut _pwm; + Timeout toff; +}; + +} +#endif