No.9 Robotics / Mbed 2 deprecated Robotics_DCMotor

Dependencies:   mbed

Fork of Robotics_Lab_DCMotor by LDSC_Robotics

Revision:
10:7954ec17021d
Parent:
6:da43b63ffb24
--- a/main.cpp	Thu Apr 14 09:29:00 2016 +0000
+++ b/main.cpp	Thu Apr 14 16:50:02 2016 +0000
@@ -38,7 +38,7 @@
 
 char speedCmd;
 
-int8_t stateA_1=0, stateB_1=0, stateA_2=0, stateB_2=0;
+int8_t stateA_1 = 0, stateB_1 = 0, stateA_2 = 0, stateB_2 = 0;
 int8_t state_1 = 0, state_1_old = 0, state_2 = 0, state_2_old = 0;
 
 int v1Count = 0;
@@ -67,34 +67,34 @@
             
             if (speedCmd == 'a')
             { 
-                v1_ref = v1_ref + 10;
-                v2_ref = v2_ref + 10;
+                v1_ref = v1_ref + 10.0f;
+                v2_ref = v2_ref + 10.0f;
             }
             else if (speedCmd == 's')
             {
-                v1_ref = v1_ref - 10;
-                v2_ref = v2_ref - 10;
+                v1_ref = v1_ref - 10.0f;
+                v2_ref = v2_ref - 10.0f;
             }
             else if (speedCmd == 'q')
             {
-                v1_ref = v1_ref + 20;
-                v2_ref = v2_ref + 20;
+                v1_ref = v1_ref + 20.0f;
+                v2_ref = v2_ref + 20.0f;
             }
             else if (speedCmd == 'w')
             {
-                v1_ref = v1_ref - 20;
-                v2_ref = v2_ref - 20;
+                v1_ref = v1_ref - 20.0f;
+                v2_ref = v2_ref - 20.0f;
             }
             
-            if (v1_ref < -100)
-                v1_ref = -100;
-            else if (v1_ref > 100)
-                v1_ref = 100;
+            if (v1_ref < -100.0f)
+                v1_ref = -100.0f;
+            else if (v1_ref > 100.0f)
+                v1_ref = 100.0f;
                 
-            if (v2_ref < -100)
-                v2_ref = -100;
-            else if (v2_ref > 100)
-                v2_ref = 100;
+            if (v2_ref < -100.0f)
+                v2_ref = -100.0f;
+            else if (v2_ref > 100.0f)
+                v2_ref = 100.0f;
         }
     }
 }