Thomas Burgers / Mbed 2 deprecated ZZ-TheChenneRobot

Dependencies:   Encoder HIDScope MODSERIAL QEI biquadFilter mbed

Revision:
5:8fb74a22fe3c
Parent:
4:9fdad59c03d6
Child:
6:8a62f76a1f68
--- a/main.cpp	Mon Oct 05 19:07:30 2015 +0000
+++ b/main.cpp	Mon Oct 05 19:13:14 2015 +0000
@@ -7,6 +7,7 @@
 
     /* MODSERIAL to get non-blocking Serial*/
     MODSERIAL pc(USBTX,USBRX);
+    DigitalIn button(PTA4); // PTA4 is used as a button controller (0 when pressed and 1 when not pressed)
 
 void keep_in_range(double * in, double min, double max);
 
@@ -51,7 +52,15 @@
     
     //INFINITE LOOP
     
-    while(1) {
+    while(1) 
+        {
+         if (button.read() < 0.5) {   //if button pressed
+            motordir = 0; // zero is clockwise (front view)
+            pwm_motor = 0.5f; // motorspeed
+            pc.printf("positie = %d \r\n", motor1.getPulses());
+            }
+        else
+        {
         /* Wait until looptimer flag is true. */
         while(looptimerflag != true);
 
@@ -97,6 +106,7 @@
         pwm_motor=(abs(pwm_to_motor));
     }
 }
+}
 
 
 // Keep in range function
@@ -127,4 +137,4 @@
 const float offset = 0.5;
 const float gain = 4.0;
 return (input-offset)*gain;
-}
\ No newline at end of file
+}