![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Teacher version
Dependencies: mbed lib_workshop_2019
src/test_motor/ft_run_motor.cpp
- Committer:
- gvaquette
- Date:
- 2019-10-24
- Revision:
- 5:d99659a45cab
- Parent:
- 4:bf5caf4c0c88
File content as of revision 5:d99659a45cab:
#include "mbed.h" #include "test_motor.h" /**********************************************************************/ /** ft_run_motor **/ /* Args : - direction (e_direction): direction to turn the motor */ /* - duty_cycle (double): duty cycle for the PWM */ /* - pwm_mot (PwmOut): pin to set the PWM */ /* - dirA and dirB (DigitalOut): Pins to set the direction */ /**********************************************************************/ void ft_run_motor( e_direction direction, double duty_cycle, PwmOut pwm_mot, DigitalOut dirA, DigitalOut dirB) { /* TO DO : define direction */ if (direction == FORWARD) { dirA = 1; dirB = 0; } else // direction == BACKWARD { dirA = 0; dirB = 1; } /* TO DO : apply duty cycle to pwm_mot */ pwm_mot = duty_cycle; }