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.
Dependencies: mbed
Zvuk.cpp
- Committer:
 - tglatki
 - Date:
 - 2020-11-19
 - Revision:
 - 1:68f9357c45ff
 - Parent:
 - 0:6473ed3e3821
 
File content as of revision 1:68f9357c45ff:
#include "mbed.h"
#include "Zvuk.h"  //zvuk stvoren pomoću Buzzera
                  //vremensko ograničenje korištenja Buzzera
using namespace mbed; // Zvuk objekt s pinom na mikrokontroleru
  
Zvuk::Zvuk(PinName pin) : _pwm(pin) 
{
    _pwm.write(0.0);     
}
void Zvuk::nobeep() 
{
    _pwm.write(0.0);
}
 
void Zvuk::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,&Zvuk::nobeep, time); //vrijeme zaustavljanja
}