code

Fork of Motor by Simon Ford

Revision:
3:19cff7a4b43e
Parent:
2:f265e441bcd9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Moteur.cpp	Wed Apr 11 14:35:42 2018 +0000
@@ -0,0 +1,24 @@
+#include "Moteur.h"
+
+#include "mbed.h"
+
+Moteur::Moteur(PinName pwm, PinName avancer, PinName reculer): _pwm(pwm), _avancer(avancer), _reculer(reculer) {
+
+    // Set initial condition of PWM
+    _pwm.period(0.001);
+    _pwm = 0;
+
+    // Initial condition of output enables
+    _avancer = 0;
+    _reculer = 0;
+}
+
+void Moteur::vitesse(float vit) {
+    
+    _avancer = (vit> 0.0);
+    _reculer = (vit < 0.0);
+    _pwm = abs(vit);
+}
+
+
+