Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
chinetion
Date:
Thu Oct 15 19:10:23 2015 +0000
Commit message:
Fin;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r f17d9dc54c1d main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 15 19:10:23 2015 +0000
@@ -0,0 +1,56 @@
+#include "mbed.h"
+
+
+DigitalOut led[] = {D2,D3,D4,D5,D6,D7,D8,D9};
+DigitalIn In[] = {D10,D11,D12};
+double speed=0.1;
+int pat = 1,tog=0;
+void check(){
+    tog=0;
+    if(In[0]){pat++;tog=1;}
+    if(In[1])speed+=0.02;
+    if(In[2])speed-=0.02;
+    if(speed<=0.02)speed=0.02;
+    else if(speed>=1)speed=1;
+    if(pat>3)pat=1;
+}
+int main(){
+    
+  while(1){
+  if(pat==1){
+        for(int x=0;x<=7;x++){
+              led[x]=1;
+              wait(speed);
+              led[x]=0;
+                check();if(tog==1)break;
+        }
+    }
+    if(pat==2){
+        for(int x=0;x<=7;x++){
+              led[x]=1;
+              wait(speed);
+              check();if(tog==1)break;
+        }
+        for(int x=0;x<=7;x++){
+              led[x]=0;
+              wait(speed);
+              check();if(tog==1)break;
+        }
+        
+    }
+    if(pat==3){
+        for(int x=0;x<=3;x++){
+              led[x]=1;
+              led[7-x]=1;
+              wait(speed);
+              check();if(tog==1)break;
+        }
+        for(int x=3;x>=0;x--){
+              led[x]=0;
+              led[7-x]=0;
+              wait(speed);
+              check();if(tog==1)break;
+        }
+  }
+  }
+  }
diff -r 000000000000 -r f17d9dc54c1d mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Oct 15 19:10:23 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/34e6b704fe68
\ No newline at end of file