Soft robot team / Mbed OS Robot_team1

Dependencies:   QEI Motordriver ros_lib_melodic

Committer:
florine_van
Date:
Wed Oct 23 10:38:36 2019 +0000
Revision:
6:858a5116688e
Parent:
5:8ef79eebbc97
Child:
11:35809512ec11
Correct motors issue; Clean code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
florine_van 6:858a5116688e 1 #include "mbed.h"
florine_van 6:858a5116688e 2
florine_van 5:8ef79eebbc97 3 #include "Motor.h"
florine_van 5:8ef79eebbc97 4
florine_van 5:8ef79eebbc97 5 ///////////////////////////////////////////////////////////////////
florine_van 5:8ef79eebbc97 6 // Constructor
florine_van 5:8ef79eebbc97 7 ///////////////////////////////////////////////////////////////////
florine_van 5:8ef79eebbc97 8 Motor::Motor(PinName in1, PinName in2, PinName pwm)
florine_van 6:858a5116688e 9 : in1(in1), in2(in2), pwm(pwm)
florine_van 6:858a5116688e 10 {
florine_van 6:858a5116688e 11 this->pwm.period_ms(10);
florine_van 6:858a5116688e 12 }
florine_van 5:8ef79eebbc97 13
florine_van 5:8ef79eebbc97 14 ///////////////////////////////////////////////////////////////////
florine_van 5:8ef79eebbc97 15 // Public methods
florine_van 5:8ef79eebbc97 16 ///////////////////////////////////////////////////////////////////
florine_van 5:8ef79eebbc97 17
florine_van 5:8ef79eebbc97 18 void Motor::moveForward()
florine_van 5:8ef79eebbc97 19 {
florine_van 5:8ef79eebbc97 20 in1 = 1;
florine_van 6:858a5116688e 21 in2 = 0;
florine_van 5:8ef79eebbc97 22 }
florine_van 5:8ef79eebbc97 23
florine_van 6:858a5116688e 24 void Motor::moveBackward()
florine_van 5:8ef79eebbc97 25 {
florine_van 6:858a5116688e 26 in1 = 0;
florine_van 5:8ef79eebbc97 27 in2 = 1;
florine_van 5:8ef79eebbc97 28 }
florine_van 5:8ef79eebbc97 29
florine_van 6:858a5116688e 30 void Motor::setSpeed(float speed)
florine_van 5:8ef79eebbc97 31 {
florine_van 6:858a5116688e 32 pwm.write(speed);
florine_van 5:8ef79eebbc97 33 }