Soft robot team / Mbed OS Robot_team1

Dependencies:   QEI Motordriver ros_lib_melodic

motor/Motor.cpp

Committer:
florine_van
Date:
2019-10-22
Revision:
5:8ef79eebbc97
Parent:
0:57855aafa907
Child:
6:858a5116688e

File content as of revision 5:8ef79eebbc97:

#include "Motor.h"

///////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////
Motor::Motor(PinName in1, PinName in2, PinName pwm)
: in1(in1), in2(in2), pwm(pwm) {}

///////////////////////////////////////////////////////////////////
// Public methods
///////////////////////////////////////////////////////////////////

//TODO
void Motor::moveForward()
{
    in1 = 1; 
    in2 = 0;
    
    pwm.period_ms(10);
    pwm.write(0.5f);
}

//TODO
void Motor::moveBack()
{
    pwm.period_ms(10);
    pwm.write(0.5f);
}

//TODO
void Motor::turnLeft()
{
    in1 = 0;
    in2 = 1;
    
    pwm.period_ms(10);
    pwm.write(0.5f);
}

//TODO
void Motor::turnRight()
{
    
    pwm.period_ms(10);
    pwm.write(0.5f);
}