smaller mbed board traffic lights

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
jcochra
Date:
Tue Jun 07 14:40:48 2016 +0000
Commit message:
TrafficLightSequence for smaller mbed board;

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
diff -r 000000000000 -r 60bfe7e2affd main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jun 07 14:40:48 2016 +0000
@@ -0,0 +1,82 @@
+#include "mbed.h"
+
+//Traffic Light Timing, sets a variable high when the light is Red
+DigitalOut RED(p15);
+DigitalOut GRED(p16);
+DigitalOut AMBER(p17);
+DigitalOut GAMBER(p18);
+DigitalOut GREEN(p19);
+DigitalOut GGREEN(p20);
+
+int flag;
+
+void stop(void)
+{       flag = 1;
+        RED = 1;
+        GRED = 0;
+        AMBER = 0;
+        GAMBER = 0;
+        GREEN = 0;
+        GGREEN = 0;
+        wait(3);
+ }
+    
+    
+    
+void hold(void)
+    { flag = 0;
+    int x;
+    for(x=0; x<3; x++)
+    {   RED = 1;
+        GRED = 0;
+        AMBER = 0;
+        GAMBER = 0;
+        GREEN = 0;
+        GGREEN = 0;
+        wait(0.5);
+        RED = 1;
+        GRED = 0;
+        AMBER = 1;
+        GAMBER = 0;
+        GREEN = 0;
+        GGREEN = 0;
+        wait(0.5);
+        }
+        }
+        
+void go(void)
+    {   flag = 0;
+        RED = 0;
+        GRED = 0;
+        AMBER = 0;
+        GAMBER = 0;
+        GREEN = 1;
+        GGREEN = 0;
+        wait(3);
+        }
+
+void waiting(void)
+{       flag = 0;
+        RED = 0;
+        GRED = 0;
+        AMBER = 1;
+        GAMBER = 0;
+        GREEN = 0;
+        GGREEN = 0;
+        wait(1.5f);
+        }
+
+
+int main() {
+    while(1)
+    {
+    stop();
+    hold();
+    go();
+    waiting();
+    
+}
+        
+}
+
+   
\ No newline at end of file
diff -r 000000000000 -r 60bfe7e2affd mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Jun 07 14:40:48 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/487b796308b0
\ No newline at end of file