Six crescent shaped legs

Dependencies:   mbed

Revision:
0:0b7259fdb68a
Child:
1:8b0322a353f4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Mar 24 11:01:18 2016 +0000
@@ -0,0 +1,56 @@
+#include "mbed.h"
+#include "time.h"
+
+Timer timer;
+PwmOut mypwm(PB_0);
+DigitalOut dir1(PC_0);
+DigitalOut dir2(PC_1);
+InterruptIn encA(PA_0);
+InterruptIn bt(USER_BUTTON);
+Serial pc(SERIAL_TX, SERIAL_RX);
+
+int iLoe = 0;
+int isItTime = 0;
+int iUus = 0;
+int iAeg = 0;
+//int iVan[2] = {0,0};
+double dPwm = 0.01;
+int lastB= bt;
+
+void start(){
+    iUus = timer.read_us();
+    timer.reset();
+    }
+void stop(){
+    iAeg = timer.read_us();
+    }
+
+void button(){
+    isItTime = 1;
+    }
+
+int main(){
+    encA.rise(&start);
+    encA.fall(&stop);
+    bt.fall(&button);
+    timer.start();
+    mypwm.write(dPwm);
+    //mypwm.period_ms(10);
+    //mypwm.pulsewidth_ms(4);
+    dir1 = 1;
+    dir2 = 0;
+
+    while(1) {
+        if (isItTime){
+            isItTime = 0;
+            dPwm = dPwm + 0.1;
+            if (dPwm>=1){
+                dPwm--;
+            }
+            mypwm.write(dPwm);
+        }
+        else {
+            pc.printf("%f: %d/%d\n",dPwm,iUus,iAeg);
+        }
+    }
+}