TVZ2019 / Mbed 2 deprecated Semafor

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
petracar
Date:
Sat Nov 16 11:03:15 2019 +0000
Commit message:
Semafor za aute i pjesake

Changed in this revision

main.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
svijetla.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Nov 16 11:03:15 2019 +0000
@@ -0,0 +1,52 @@
+#include "mbed.h"
+#include "semafor.h"
+
+Traffic crveno (p7);
+Traffic zuto (p6);
+Traffic zeleno (p5);
+Traffic zeleno_p (p20);
+Traffic crveno_p (p19);
+InterruptIn tipkalo(p8);
+Ticker tik1;
+
+int t=0,p;
+
+void tiker1(){
+    t=t+1;
+    }
+
+void pjesaci(){
+   p=1;
+    }
+    
+void semafor2(){
+   if(t>=0 && t<200) 
+    zeleno.light_on(t, 0, 200);
+    crveno_p.light_on(t, 0, 400);
+    if(t>=200 && t<400)
+    zuto.light_on(t, 200, 400);
+    if(t>=400 && t<700){
+    crveno.light_on(t, 400, 700);
+    zeleno_p.light_on(t, 400, 500);}
+    if(t>=600 && t<700)
+    zuto.light_on(t,600, 700);
+    if (t>=500)
+    crveno_p.light_on(t,500,700);
+        }
+
+int main(){
+  tik1.attach(&tiker1, 0.01);
+  while(1){
+     if(p!=1)
+        t=0;
+        zeleno.light_on(t, 0, 1);
+        crveno_p.light_on(t, 0, 1);
+     tipkalo.fall(&pjesaci);
+     if(p==1 && t<700)
+        semafor2();
+     if(p==1 && t>700){
+        t=0;
+        p=0;
+        } 
+      }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Nov 16 11:03:15 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/svijetla.lib	Sat Nov 16 11:03:15 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/petracar/code/svijetla/#96fe6ca7047c