Soft robot team / Mbed OS Robot_team1

Dependencies:   QEI Motordriver ros_lib_melodic

motor/Motor.cpp

Committer:
florine_van
Date:
2019-11-15
Revision:
12:817da876ae2f
Parent:
11:35809512ec11

File content as of revision 12:817da876ae2f:

#include "mbed.h"

#include "Motor.h"

///////////////////////////////////////////////////////////////////
// Constructor
///////////////////////////////////////////////////////////////////
Motor::Motor(PinName in1, PinName in2, PinName pwm)
: in1(in1), in2(in2), pwm(pwm) 
{
    this->pwm.period_ms(10);
}

///////////////////////////////////////////////////////////////////
// Public methods
///////////////////////////////////////////////////////////////////
void Motor::stop()
{
    in1 = 0;
    in2 = 0;
}

void Motor::moveForward()
{
    in1 = 1; 
    in2 = 0;    
}

void Motor::moveBackward()
{
    in1 = 0; 
    in2 = 1;
}

void Motor::setSpeed(float speed)
{
    pwm.write(speed);
}