Final

Files at this revision

API Documentation at this revision

Comitter:
jbeason3
Date:
Wed Nov 06 04:53:49 2019 +0000
Commit message:
Final

Changed in this revision

Motor_Driver.cpp Show annotated file Show diff for this revision Revisions of this file
Motor_Driver.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r e0bfe92fd649 Motor_Driver.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor_Driver.cpp	Wed Nov 06 04:53:49 2019 +0000
@@ -0,0 +1,22 @@
+#include "Motor_Driver.h"
+
+//initialization function
+BLDR::BLDR(PinName in1, PinName in2, PinName pwm):
+        _pwm(pwm), _in1(in1), _in2(in2) {
+    _pwm.period(0.01);
+}
+
+void BLDR::set_dir(int dir){
+    if(dir==1){
+        _in1=1;
+        _in2=0;   
+    }
+    if(dir==-1){
+        _in1=0;
+        _in2=1;   
+    }
+}
+
+void BLDR::set_duty(float dc){
+    _pwm.write(dc);
+}
\ No newline at end of file
diff -r 000000000000 -r e0bfe92fd649 Motor_Driver.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Motor_Driver.h	Wed Nov 06 04:53:49 2019 +0000
@@ -0,0 +1,20 @@
+#ifndef Motor_Driver_H
+#define Motor_Driver_H
+
+#include "mbed.h"
+
+class BLDR {
+public:
+    BLDR(PinName in1, PinName in2, PinName pmw);
+    void set_dir(int dir);
+    void set_duty(float dc);
+    
+private:
+    PwmOut _pwm;
+    DigitalOut _in1;
+    DigitalOut _in2;
+    
+};
+
+//needed ending text
+#endif
\ No newline at end of file