ProjectGroep23 / Mbed 2 deprecated Kinematics

Dependencies:   MODSERIAL QEI mbed-dsp mbed

Fork of Motorcode by ProjectGroep23

Files at this revision

API Documentation at this revision

Comitter:
rachieldb
Date:
Mon Oct 01 12:47:32 2018 +0000
Parent:
7:e21056555296
Child:
9:466dff9ae128
Commit message:
draaien van beide richtingen toegevoegd;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Sep 25 11:55:40 2018 +0000
+++ b/main.cpp	Mon Oct 01 12:47:32 2018 +0000
@@ -32,9 +32,12 @@
   
     while (true)
     {
-            pwmpin.write(pot1.read());
-            direct = 1;
-            pc.printf("potmeter: %f, encoder: %i \r\n", pot1.read(), encoder.getPulses());
+            float pot1_float = pot1.read();
+            float pot1_motor = (pot1_float * 2.0f) - 1.0f;
+            int mot1_direction = pot1_motor >= 0;
+            pwmpin.write(fabs(pot1_motor));
+            direct = mot1_direction;
+            pc.printf("potmeter: %f, encoder: %i \r\n", pot1_motor, encoder.getPulses());
             wait(0.2f);
     }
 }