Nadzor opterećenja

https://os.mbed.com/media/uploads/nikolarp/shema_fb_thumb.jpg

Files at this revision

API Documentation at this revision

Comitter:
nikolarp
Date:
Mon Apr 05 14:20:16 2021 +0000
Parent:
0:b6c8e3914720
Commit message:
2.

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b6c8e3914720 -r db40e2456381 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Apr 05 14:20:16 2021 +0000
@@ -0,0 +1,55 @@
+#include "mbed.h"
+#include "IO.h"
+#include "SegDisplay.h"
+Serial pc(USBTX, USBRX);
+Ticker flip;
+Timer debounce;
+float ADCdata;
+void toggle(){
+    if (debounce.read_ms()>200) 
+        Alarm=1;       
+        }        
+void flip1(){
+    crvena = !crvena;
+    zelena = !zelena;
+    zuta =!zuta;
+    }
+int main(){
+    LED();
+    SegInit();
+    debounce.start();
+button.rise(&toggle);
+    while (1) 
+    {    
+ADCdata=Ain;
+pc.printf("%f \n\r",ADCdata);
+if(ADCdata>=0.1 && ADCdata<0.49){
+    zelena=1;
+    zuta=0;
+    crvena=0;
+}
+else if(ADCdata>=0.5 && ADCdata<0.79){
+    zelena=1;
+    zuta=1;
+    crvena=0;
+}
+else if(ADCdata>=0.8 && ADCdata<=0.89){
+    zelena=1;
+    zuta=1;
+    crvena=1;
+}
+else if(ADCdata>=0.0 && ADCdata<0.09){
+    zelena=0;
+    zuta=0;
+    crvena=0;
+}
+else if(ADCdata>=0.9 && ADCdata<=1.0){   
+    flip.attach(&flip1, 0.2);
+    wait(0.4);
+    flip.detach();
+}
+Seg1 = SegConvert(ADCdata*10);
+wait (0.5);
+    }
+}
+    
\ No newline at end of file