LEDs blinken von LED1-LED4,und fangen an von momentane Position an. l

Dependencies:   mbed

Revision:
0:72b3da7b1d49
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Jan 12 19:59:58 2020 +0000
@@ -0,0 +1,57 @@
+#include "mbed.h"
+ 
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+uint8_t pos = 0;
+uint8_t shift = 0;          // change the value between 0 and 3
+ 
+int main() {
+    while (1) {
+        pos = (1 << shift); // shift left
+        if(pos == 0b00001000)
+           { led4 = 1;
+            wait_ms(100);
+            led4=0;
+            led1=1;
+            wait(0.1);
+            led1=0;
+            led2 = 1;
+            wait_ms(100);
+            led2=0;
+            led3 = 1;
+            wait_ms(100);
+            led3=0;
+           }
+            if(pos == 0b00000100)
+           { led3 = 1;
+            wait_ms(100);
+            led3=0;
+            led4=1;
+            wait(0.1);
+            led4=0;
+            led1 = 1;
+            wait_ms(100);
+            led1=0;
+            led2= 1;
+            wait_ms(100);
+            led2=0;
+           }
+          if(pos == 0b00000001)
+           { led1 = 1;
+            wait_ms(400);
+            led1=0;
+            led2=1;
+            wait(0.4);
+            led2=0;
+            led3 = 1;
+            wait_ms(400);
+            led3=0;
+            led4 = 1;
+            wait_ms(400);
+            led4=0;
+           }   
+    }
+}