Minh Nguyen / MotorDriver
Revision:
0:c58a5bbd417a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MotorDriver.cpp	Tue Feb 09 23:53:44 2021 +0000
@@ -0,0 +1,58 @@
+//INCLUDES
+#include "MotorDriver.h"
+#include "PinAssignment.h"
+
+MotorDriver::MotorDriver() : ena(PIN_ENA),enb(PIN_ENB),intp(PIN_INTP),intn(PIN_INTN) {}
+
+//moveForward
+void MotorDriver::moveForward(int s)
+{
+    switch(s)
+    {
+        case M1:
+            ena = 1;
+            enb = 0;
+            break;
+        case M2:
+            ena = 0;
+            enb = 1;
+            break;
+        case M_ALL:
+            ena = 1;
+            enb = 1;
+            break;
+    }
+    intp = 1;
+    intn = 0;
+}
+
+//moveBackward
+void MotorDriver::moveBackward(int s)
+{
+    switch(s)
+    {
+        case M1:
+            ena = 1;
+            enb = 0;
+            break;
+        case M2:
+            ena = 0;
+            enb = 1;
+            break;
+        case M_ALL:
+            ena = 1;
+            enb = 1;
+            break;
+    }
+    intp = 0;
+    intn = 1;
+}
+
+//stop
+void MotorDriver::stop()
+{
+    ena = 0;
+    enb = 0;
+    intp = 0;
+    intn = 0;
+}
\ No newline at end of file