An example code for using the motorshield for 2.74

Dependencies:   QEI_pmw MotorShield

Revision:
3:1eee0d9f1223
Parent:
2:358bdcaaf496
--- a/main.cpp	Sat Sep 12 14:34:20 2020 +0000
+++ b/main.cpp	Sat Sep 12 17:12:04 2020 +0000
@@ -20,9 +20,9 @@
     t.reset();
     t.start();
     encoderA.reset();
-    int32_t position;
-    int32_t velocity;
-    int32_t current;
+    float position;
+    float velocity;
+    float current;
     motorShield.motorAWrite(0, 0); //turn motor A off
     
     //use the motor shield as follows:
@@ -40,7 +40,7 @@
         velocity = 0; //MODIFY THIS
         current = motorShield.readCurrentA()*(30.0/65536.0)-15; //read current for motor A in amps. Note: this is a slightly different current sensor so its a different conversion than last lab.
         
-        pc.printf("Current reading: %i Amps, Velocity: %i, Angle: %i \n\r", current, velocity, position);
+        pc.printf("Current reading: %f Amps, Velocity: %f, Angle: %f \n\r", current, velocity, position);
         
         wait(.01); //run control loop at 100Hz
     }