Inverted Pendulum / Mbed 2 deprecated IP-Interface

Dependencies:   mbed QEI

Revision:
19:0e9bf6d61d0d
Parent:
18:5a1c351094d2
Child:
20:8063c82bbb35
--- a/main.cpp	Wed Nov 16 02:10:43 2016 +0000
+++ b/main.cpp	Wed Nov 16 03:44:19 2016 +0000
@@ -76,15 +76,15 @@
         printf("voltage %%: %f  pulse: %i", pend.get_voltage(), encoder.getPulses());
     }
 }
-void move_pulses(int pulses){ // find number of pulses from the encoder going from one end to the other.
+void move_pulses(int pulses, int wait){ // find number of pulses from the encoder going from one end to the other.
     int start = encoder.getPulses();
     if(pulses >=0){
         while(encoder.getPulses() < start + pulses){
-            motor.clockwise();    
+            motor.clockwise(wait);    
         } 
     }else{
         while(encoder.getPulses() > start + pulses)
-            motor.anticlockwise();
+            motor.anticlockwise(wait);
         } 
 }
 void disttopulse(int distance) //find amount of pulses to distance
@@ -119,8 +119,17 @@
     }
 }
 int main() {
-    while(1)
-        printf("Pulses: %i\r\n", encoder.getPulses());
+    int wait = 600;
+    printf("Hi");
+    while(wait > 10)
+    {
+        printf("Current wait tme is %d",wait);
+        move_pulses(-5000,wait);
+ //     printf("Took: %lf \r\n",elapsed);
+        move_pulses(5000,wait);\
+ //     printf("Took: %lf \r\n",elapsed);
+        wait-=25;
+    }
     //motor.step_clockwise(100,1500);
     //motor.step_clockwise(100,1000);
     //motor.step_clockwise(100,700);