led test for academic practice

Dependencies:   mbed

Fork of LED_FLASH_TEST_SU by naoto tanaka

Revision:
0:68fbb882ee59
Child:
1:d1e024be1615
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Apr 10 12:23:30 2014 +0000
@@ -0,0 +1,59 @@
+#include "mbed.h"
+
+BusOut leds(P1_13, P1_14, P1_22, P0_17, P0_18, P0_19, P1_15, P0_1);
+
+int main()
+{
+    unsigned char hex = 0x00;
+    int state = 0, count = 0;
+    while(1)
+    {
+        // single led flash
+        while(state == 0)
+        {
+            count++;
+            leds = 1;
+            if(count == 20)
+            {
+                state++;
+            }
+            wait(0.1);
+        }
+        
+        hex = 0xff;
+        count = 0;
+        
+        //all led blink
+        while(state == 1)
+        {
+            count++;
+            //exclusive or.(all bits flipping)
+            leds = hex ^ 0xff;
+            if(count == 6)
+            {
+                state++;
+            }
+            wait(0.5);
+        }
+        
+        hex = 0x01;
+        count = 0;
+        
+        //flashing led rotate
+        while(state == 2)
+        {
+            count++;
+            //bit rotate
+            leds = hex << 1;
+            if(hex == 0)
+            {
+                hex = 0x01;
+            }
+            if(count == 24)
+            {
+                state = 0;
+            }
+            wait(0.125);
+        }
+    }
+}