Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Buzzer.cpp
- Committer:
- dpavetic
- Date:
- 2022-11-27
- Revision:
- 0:f867aece57de
File content as of revision 0:f867aece57de:
#include "Buzzer.h"
using namespace mbed;
Buzzer::Buzzer(PinName pin) : _pwm(pin) { _pwm.write(0.0); }
void Buzzer::silence() { _pwm.write(0.0); }
void empty() {
}
/**
* Buzzer with given frequency and rithm.
*
* @param frequency - the frequency of the tone in Hz
* @param rithm - rithm of the song
*/
void Buzzer::buzz(float freq, float rithm) {
_pwm.period(1.0 / freq);
_pwm.write(0.5f);
ThisThread::sleep_for(Kernel::Clock::duration_u32((int)(rithm * 500)));
}