Make noise with a piezo buzzer. Use a pwm pin.

Dependents:   Cave_Runner popcorn default USBMIDI_Buzzer ... more

beep.h

Committer:
dreschpe
Date:
2011-02-01
Revision:
0:18e4a9c978ec
Child:
1:ddccf0a4a414

File content as of revision 0:18e4a9c978ec:

#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