Mihajlo Djordjevic 2020/0438

Dependencies:   mbed

Revision:
0:849fcc3d83a1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 13 08:59:34 2021 +0000
@@ -0,0 +1,44 @@
+// Mihajlo Djordjevic 2020/0438
+// Uvoz biblioteke
+#include "mbed.h"
+//Makro
+#define POLLING_PERIOD 20
+#define MAX_POT1 0.9f
+#define MAX_POT2 0.8f
+#define MAX_PERIOD 1.05
+// Glavne promenljive
+PwmOut buzzer(PA_11);
+AnalogIn pot1(PA_0);
+AnalogIn pot2(PA_1);
+InterruptIn button(PC_9);
+
+
+// Funkcije
+void ISR_procenat(void);
+
+int main () {
+    
+    
+    while(true) {
+        button.fall(ISR_procenat);
+        if(pot1.read() < MAX_POT1){
+            buzzer = pot1.read();
+            }
+        else buzzer = MAX_POT1;
+        
+        
+        printf(" pot1 : %1.2f pot2 : %1.2f \r", pot1.read(),pot2.read());
+        
+        float period;
+        if(pot2.read() < MAX_POT2){
+            period = 5 - pot2.read() * 4.95;
+            buzzer.period_ms(period);
+        }
+        else buzzer.period_ms(MAX_PERIOD);
+        wait_ms(POLLING_PERIOD);
+        }
+}
+void ISR_procenat(){
+    
+    }   
+    
\ No newline at end of file