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

Dependents:   Cave_Runner popcorn default USBMIDI_Buzzer ... more

Embed: (wiki syntax)

« Back to documentation index

mbed Namespace Reference

mbed Namespace Reference

class to make sound 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...


Detailed Description

class to make sound 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 with 1Khz for 0.5 seconds
 #include "mbed.h"
 #include "beep.h"
 
 Beep buzzer(p21);
 
 int main() {
        ...
   buzzer.beep(1000,0.5);    
       ...
 }