encoder verwerkt

Dependencies:   MODSERIAL QEI mbed

Fork of motor_control by Floor Couwenberg

Revision:
4:d39f84608204
Parent:
3:a50f2ce05e1f
Child:
5:bb97950558bd
--- a/main.cpp	Fri Sep 30 11:48:01 2016 +0000
+++ b/main.cpp	Fri Sep 30 11:56:15 2016 +0000
@@ -18,15 +18,22 @@
 int main ()
 {
     pc.baud(115200); //contact maken met computer
-    int counts; 
-    while (knop==1)
-    { //als knop is aan dan
+    volatile int counts; 
+    while(true)
+    {
+    if (button==1)
+        { //als knop is aan dan
         led=1;
-        motor = CCW;
+        motor1= CCW;
         pwm_motor1=2.5;
-        QEI Encoder(D12,D13,NC,32);
+        QEI Encoder(D12,D13,NC,64);
         counts = Encoder.getPulses();
         pc.printf("encoder counts %i", counts);                          
      
+        }
+    else{ 
+    led=!led;
+    pwm_motor1=0;
+        }
     }
 }
\ No newline at end of file