code

Fork of Motor by Simon Ford

Moteur.cpp

Committer:
PeaceBearer
Date:
2018-04-11
Revision:
3:19cff7a4b43e
Parent:
Motor.cpp@ 2:f265e441bcd9

File content as of revision 3:19cff7a4b43e:

#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);
}