Soft robot team / Mbed OS Robot_team1

Dependencies:   QEI Motordriver ros_lib_melodic

Revision:
6:858a5116688e
Parent:
5:8ef79eebbc97
Child:
11:35809512ec11
diff -r 8ef79eebbc97 -r 858a5116688e motor/Motor.cpp
--- a/motor/Motor.cpp	Tue Oct 22 15:06:44 2019 +0000
+++ b/motor/Motor.cpp	Wed Oct 23 10:38:36 2019 +0000
@@ -1,47 +1,33 @@
+#include "mbed.h"
+
 #include "Motor.h"
 
 ///////////////////////////////////////////////////////////////////
 // Constructor
 ///////////////////////////////////////////////////////////////////
 Motor::Motor(PinName in1, PinName in2, PinName pwm)
-: in1(in1), in2(in2), pwm(pwm) {}
+: in1(in1), in2(in2), pwm(pwm) 
+{
+    this->pwm.period_ms(10);
+}
 
 ///////////////////////////////////////////////////////////////////
 // Public methods
 ///////////////////////////////////////////////////////////////////
 
-//TODO
 void Motor::moveForward()
 {
     in1 = 1; 
-    in2 = 0;
-    
-    pwm.period_ms(10);
-    pwm.write(0.5f);
-}
-
-//TODO
-void Motor::moveBack()
-{
-    pwm.period_ms(10);
-    pwm.write(0.5f);
+    in2 = 0;    
 }
 
-//TODO
-void Motor::turnLeft()
+void Motor::moveBackward()
 {
-    in1 = 0;
+    in1 = 0; 
     in2 = 1;
-    
-    pwm.period_ms(10);
-    pwm.write(0.5f);
 }
 
-//TODO
-void Motor::turnRight()
+void Motor::setSpeed(float speed)
 {
-    
-    pwm.period_ms(10);
-    pwm.write(0.5f);
+    pwm.write(speed);
 }
-