mbed_blinky_LPC1114

Dependencies:   mbed

Fork of mbed_blinky by Mbed

Revision:
7:f43f82ebd32a
Parent:
4:81cea7a352b0
--- a/main.cpp	Fri May 09 19:58:03 2014 +0300
+++ b/main.cpp	Mon Mar 23 03:31:08 2015 +0000
@@ -1,12 +1,24 @@
 #include "mbed.h"
 
-DigitalOut myled(LED1);
+DigitalOut leds[] = {dp1, dp2, dp4, dp6, dp9, dp10, dp11, dp13, dp14};
+int numLeds = sizeof(leds)/sizeof(DigitalOut);
 
 int main() {
+    double w_time = 0.05;
     while(1) {
-        myled = 1;
-        wait(0.2);
-        myled = 0;
-        wait(0.2);
+        for (int previous, i = 0; i < numLeds; i++){
+            if (i == 0) previous = (numLeds - 1);
+            else previous = i - 1;
+            leds[i] = 1;
+            leds[previous] = 0;
+            wait(w_time);
+        }
+        for (int previous, i = numLeds - 1; i > 0; i--){
+            if (i == 0) previous = (numLeds - 1);
+            else previous = i + 1;
+            leds[i] = 1;
+            leds[previous] = 0;
+            wait(w_time);
+        }
     }
 }