Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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);
}