Biblioteka za buzzer

Revision:
0:49754bfa1d97
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/buzzer.cpp	Wed Dec 01 07:21:02 2021 +0000
@@ -0,0 +1,23 @@
+#include "buzzer.h"
+#include "mbed.h"
+
+using namespace mbed;
+
+Beep::Beep(PinName pin) : _pwm(pin)
+{
+    _pwm.write(0.0);
+}
+
+void Beep::nobeep()
+{
+    _pwm.write(0.0);
+}
+// Frekvencija u Hz i tranjanje tona u sekundama za jedan zvučni signal
+
+void Beep::beep(float freq, float time)
+{
+
+    _pwm.period(1.0/freq);
+    _pwm.write(0.5);
+    toff.attach(this,&Beep::nobeep, time);
+}
\ No newline at end of file