-

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
dkakarigi
Date:
Thu Feb 04 21:16:43 2021 +0000
Commit message:
-

Changed in this revision

Vatro.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r b85fc380ef49 Vatro.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Vatro.cpp	Thu Feb 04 21:16:43 2021 +0000
@@ -0,0 +1,84 @@
+#include "mbed.h" 
+
+
+InterruptIn prekid (USER_BUTTON); 
+AnalogIn senzor(PA_0);            
+Serial pc(USBTX, USBRX);          
+float ispis;                      
+Ticker blink;                     
+PwmOut zvuk(D2);             
+DigitalOut led(D3);         
+int restart;                      
+
+ 
+
+void flip()
+{
+
+    led=!led; 
+}
+
+void pwm() 
+{
+    zvuk.period(0.001031); 
+    zvuk=0.5; 
+    wait(0.5); 
+
+
+}
+void pwm_off()  
+{
+    zvuk=0.0;  
+    wait(0.5);  
+
+
+}
+
+
+void zaustavi()  
+{
+    blink.detach();  
+    led=0;  
+    zvuk =0.0; 
+    restart=1; 
+
+}
+
+void alarm() 
+{
+    prekid.rise(&zaustavi);  
+    blink.attach(&flip,0.5);  
+    pwm();  
+    pwm_off(); 
+
+
+}
+
+int main() 
+{
+
+    restart=0; 
+
+    while (1) 
+
+    {
+        ispis=senzor;  
+        pc.printf("%f \n\r",ispis); 
+
+        if(ispis>=0.6&&restart==0) { 
+
+
+            alarm(); 
+
+        }
+
+        if(ispis>=0.6) { 
+            blink.detach();  
+            led=0; 
+
+        }
+    }
+
+
+
+}
diff -r 000000000000 -r b85fc380ef49 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Feb 04 21:16:43 2021 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file