Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: QEI Motordriver ros_lib_melodic
Diff: motor/Motor.cpp
- Revision:
- 5:8ef79eebbc97
- Parent:
- 0:57855aafa907
- Child:
- 6:858a5116688e
--- a/motor/Motor.cpp Tue Oct 22 11:52:32 2019 +0000
+++ b/motor/Motor.cpp Tue Oct 22 15:06:44 2019 +0000
@@ -0,0 +1,47 @@
+#include "Motor.h"
+
+///////////////////////////////////////////////////////////////////
+// Constructor
+///////////////////////////////////////////////////////////////////
+Motor::Motor(PinName in1, PinName in2, PinName pwm)
+: in1(in1), in2(in2), pwm(pwm) {}
+
+///////////////////////////////////////////////////////////////////
+// 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);
+}
+
+//TODO
+void Motor::turnLeft()
+{
+ in1 = 0;
+ in2 = 1;
+
+ pwm.period_ms(10);
+ pwm.write(0.5f);
+}
+
+//TODO
+void Motor::turnRight()
+{
+
+ pwm.period_ms(10);
+ pwm.write(0.5f);
+}
+