Mirembe Jean d'Amour / Mbed 2 deprecated ASSIGNMENT_CODES

Dependencies:   mbed

Revision:
2:a98660025857
Parent:
1:aa3ea7b4673e
Child:
3:a1263051d681
diff -r aa3ea7b4673e -r a98660025857 main.cpp
--- a/main.cpp	Sun Nov 01 12:06:47 2020 +0000
+++ b/main.cpp	Sun Nov 01 12:09:22 2020 +0000
@@ -1,11 +1,24 @@
 #include "mbed.h"
-DigitalOut trafficYellowlight(p5);   //Yellow light pin declaration 
-DigitalIn pedestrainButton(p8);    //Switch button pin declaration 
+DigitalOut trafficYellowlight(p5);  //Yellow light pin declaration 
+DigitalIn pedestrainButton(p8);  //Switch button pin declaration 
 int main() {
+    trafficYellowlight=1;  //Initialize Yellow light to ON
     while(1) 
     {
         
-         trafficYellowlight=1; //Initialize Yellow light to ON
-         wait_ms(500);
+        if(pedestrainButton & trafficYellowlight){
+            int counter=0;  // declaration and initialization of counter
+            while(counter<10){
+            counter+=1;
+            trafficYellowlight=!trafficYellowlight;  //Blinking Yellow light for 10 second
+            wait_ms(500);  //delay of 5 second
+            }
+            trafficYellowlight=0;  //switch off yellow light
+             }
+             if(!trafficYellowlight){
+                 trafficYellowlight=!pedestrainButton;  // Yellow light reamin switched OFF
+             }
+        
+             wait_ms(500);
                }
-         }
+}
\ No newline at end of file