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.
Diff: sirena.cpp
- Revision:
- 0:07997c7eb70b
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sirena.cpp Thu Feb 18 17:37:33 2021 +0000 @@ -0,0 +1,21 @@ +#include "mbed.h" +#include "sirena.h" //zvuk stvoren pomoću Buzzera + //vremensko ograničenje korištenja Buzzera +using namespace mbed; // Zvuk objekt s pinom na mikrokontroleru + +sirena::sirena(PinName pin) : _pwm(pin) // ime i ulaz(pin) +{ + _pwm.write(0.0); +} + +void sirena::nobeep() +{ + _pwm.write(0.0); +} + +void sirena::beep(float freq, float time) //frekvencija tona i trajanje u sekundama +{ + _pwm.period(1.0/freq); + _pwm.write(0.5); // duty cycle 50% + toff.attach(this,&sirena::nobeep, time); //vrijeme zaustavljanja +} \ No newline at end of file