LED 課題4 2進数 分岐のみ

Dependencies:   mbed

Fork of LED課題4 by 中野班 中野班

Revision:
0:41e610c290e1
Child:
1:93ac688c0172
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Sep 30 02:33:43 2016 +0000
@@ -0,0 +1,42 @@
+#include "mbed.h"
+ 
+AnalogIn sw1(A5);
+AnalogIn sw2(A4);
+DigitalOut out1(D7);
+DigitalOut out2(D6);
+DigitalOut out3(D5);
+DigitalOut out4(D4);
+
+int main()
+{
+    char a=0;
+    char x=0;
+    char y=0;
+    char z=0;
+    while(1){
+        for(a=0;a<=8;a++)
+        {
+            x++;
+            x = x%2;
+            out1 = !out1;
+            if(x == 0)
+            {
+                y++;
+                y = y%2;
+                out2 = !out2;
+                if(y == 0)
+                {
+                    z++;
+                    z = z%2;
+                    out3 = !out3;
+                    if(z == 0)
+                    {
+                        out4 = !out4;
+                    }
+                }
+            }
+            wait(0.25);
+        }
+    }
+}
+