Soft robot team / Mbed OS Robot_team1

Dependencies:   QEI Motordriver ros_lib_melodic

Committer:
florine_van
Date:
Tue Oct 22 15:06:44 2019 +0000
Revision:
5:8ef79eebbc97
Parent:
0:57855aafa907
Child:
6:858a5116688e
Implementation of motor class; Link to sensors in main method

Who changed what in which revision?

UserRevisionLine numberNew contents of line
florine_van 5:8ef79eebbc97 1 #include "Motor.h"
florine_van 5:8ef79eebbc97 2
florine_van 5:8ef79eebbc97 3 ///////////////////////////////////////////////////////////////////
florine_van 5:8ef79eebbc97 4 // Constructor
florine_van 5:8ef79eebbc97 5 ///////////////////////////////////////////////////////////////////
florine_van 5:8ef79eebbc97 6 Motor::Motor(PinName in1, PinName in2, PinName pwm)
florine_van 5:8ef79eebbc97 7 : in1(in1), in2(in2), pwm(pwm) {}
florine_van 5:8ef79eebbc97 8
florine_van 5:8ef79eebbc97 9 ///////////////////////////////////////////////////////////////////
florine_van 5:8ef79eebbc97 10 // Public methods
florine_van 5:8ef79eebbc97 11 ///////////////////////////////////////////////////////////////////
florine_van 5:8ef79eebbc97 12
florine_van 5:8ef79eebbc97 13 //TODO
florine_van 5:8ef79eebbc97 14 void Motor::moveForward()
florine_van 5:8ef79eebbc97 15 {
florine_van 5:8ef79eebbc97 16 in1 = 1;
florine_van 5:8ef79eebbc97 17 in2 = 0;
florine_van 5:8ef79eebbc97 18
florine_van 5:8ef79eebbc97 19 pwm.period_ms(10);
florine_van 5:8ef79eebbc97 20 pwm.write(0.5f);
florine_van 5:8ef79eebbc97 21 }
florine_van 5:8ef79eebbc97 22
florine_van 5:8ef79eebbc97 23 //TODO
florine_van 5:8ef79eebbc97 24 void Motor::moveBack()
florine_van 5:8ef79eebbc97 25 {
florine_van 5:8ef79eebbc97 26 pwm.period_ms(10);
florine_van 5:8ef79eebbc97 27 pwm.write(0.5f);
florine_van 5:8ef79eebbc97 28 }
florine_van 5:8ef79eebbc97 29
florine_van 5:8ef79eebbc97 30 //TODO
florine_van 5:8ef79eebbc97 31 void Motor::turnLeft()
florine_van 5:8ef79eebbc97 32 {
florine_van 5:8ef79eebbc97 33 in1 = 0;
florine_van 5:8ef79eebbc97 34 in2 = 1;
florine_van 5:8ef79eebbc97 35
florine_van 5:8ef79eebbc97 36 pwm.period_ms(10);
florine_van 5:8ef79eebbc97 37 pwm.write(0.5f);
florine_van 5:8ef79eebbc97 38 }
florine_van 5:8ef79eebbc97 39
florine_van 5:8ef79eebbc97 40 //TODO
florine_van 5:8ef79eebbc97 41 void Motor::turnRight()
florine_van 5:8ef79eebbc97 42 {
florine_van 5:8ef79eebbc97 43
florine_van 5:8ef79eebbc97 44 pwm.period_ms(10);
florine_van 5:8ef79eebbc97 45 pwm.write(0.5f);
florine_van 5:8ef79eebbc97 46 }
florine_van 5:8ef79eebbc97 47