LED and button system

Dependencies:   mbed

Fork of LED by CHANG rozen

Revision:
1:59cafc988b1c
Parent:
0:6e75cf3220cb
Child:
2:7bb4b5066464
diff -r 6e75cf3220cb -r 59cafc988b1c main.cpp
--- a/main.cpp	Thu Oct 19 12:36:02 2017 +0000
+++ b/main.cpp	Fri Oct 20 07:03:43 2017 +0000
@@ -3,10 +3,54 @@
 DigitalOut led1(D4);
 DigitalOut led2(D5);
 DigitalOut led3(D6);
+DigitalIn  button(D7);
 void LED_Blinkly(DigitalOut led1,DigitalOut led2,DigitalOut led3);
 // main() runs in its own thread in the OS
-int main() {
-   LED_Blinkly(led1, led2, led3);
+int main() 
+{
+    while(1)
+    {
+
+        if(button == true)
+        {
+           led1 =! led1;
+           wait(0.5);
+            led2 =! led2;
+            wait(0.5);
+            led3 =! led3;
+           wait(0.5);    
+        }
+        else
+        {
+            led1 = false;
+            led2 = false;
+            led3 = false;
+        }
+    }
+ //  int sw;
+ //   printf("1");
+ //  if(button == true)
+ //  {
+ //       sw = 1;
+ //   }
+ //   else
+ //   {
+ //       sw = 0;
+ //   }
+ //   if(sw == 1)
+ //   {
+ //       LED_Blinkly(led1,led2,led3);
+ //   }
+ //   else
+ //   {
+  //      while(false)
+   //     {
+  //          led1 = 0;
+  //          led2 = 0;
+   //         led3 = 0; 
+  //          printf("off");
+  //      }
+ //   }
 }
 void LED_Blinkly(DigitalOut led1,DigitalOut led2,DigitalOut led3){
     while(true){
@@ -16,6 +60,6 @@
         wait(0.5);
         led3 =! led3;
         wait(0.5);
+        printf("on");
     }
-}
-
+}
\ No newline at end of file