Florian Fillol / Moteur

Fork of Motor by Simon Ford

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Moteur.cpp Source File

Moteur.cpp

00001 #include "Moteur.h"
00002 
00003 #include "mbed.h"
00004 
00005 Moteur::Moteur(PinName pwm, PinName avancer, PinName reculer): _pwm(pwm), _avancer(avancer), _reculer(reculer) {
00006 
00007     // Set initial condition of PWM
00008     _pwm.period(0.001);
00009     _pwm = 0;
00010 
00011     // Initial condition of output enables
00012     _avancer = 0;
00013     _reculer = 0;
00014 }
00015 
00016 void Moteur::vitesse(float vit) {
00017     
00018     _avancer = (vit> 0.0);
00019     _reculer = (vit < 0.0);
00020     _pwm = abs(vit);
00021 }
00022 
00023 
00024