Control an H-Bridge using a PwmOut (enable) and two DigitalOuts (direction select)

Dependents:   FinalProject_Mutex

Fork of Motor by Simon Ford

Files at this revision

API Documentation at this revision

Comitter:
mpereira30
Date:
Tue Dec 06 23:02:39 2016 +0000
Parent:
2:f265e441bcd9
Commit message:
Final project before implementing threads

Changed in this revision

Motor.cpp Show annotated file Show diff for this revision Revisions of this file
Motor.h Show annotated file Show diff for this revision Revisions of this file
--- a/Motor.cpp	Tue Nov 23 16:16:43 2010 +0000
+++ b/Motor.cpp	Tue Dec 06 23:02:39 2016 +0000
@@ -25,11 +25,11 @@
 #include "mbed.h"
 
 Motor::Motor(PinName pwm, PinName fwd, PinName rev):
-        _pwm(pwm), _fwd(fwd), _rev(rev) {
+        _pwm1(pwm), _fwd(fwd), _rev(rev) {
 
     // Set initial condition of PWM
-    _pwm.period(0.001);
-    _pwm = 0;
+    _pwm1.period(0.001);
+    _pwm1 = 0;
 
     // Initial condition of output enables
     _fwd = 0;
@@ -39,7 +39,7 @@
 void Motor::speed(float speed) {
     _fwd = (speed > 0.0);
     _rev = (speed < 0.0);
-    _pwm = abs(speed);
+    _pwm1 = abs(speed);
 }
 
 
--- a/Motor.h	Tue Nov 23 16:16:43 2010 +0000
+++ b/Motor.h	Tue Dec 06 23:02:39 2016 +0000
@@ -47,7 +47,7 @@
     void speed(float speed);
 
 protected:
-    PwmOut _pwm;
+    PwmOut _pwm1;
     DigitalOut _fwd;
     DigitalOut _rev;