Outher...Miura Souta

Dependencies:   mbed MCP23017

Motor/Motor.cpp

Committer:
M_souta
Date:
2020-01-20
Revision:
0:db8d4af513c0
Child:
1:5b0303768126

File content as of revision 0:db8d4af513c0:

#include "Motor.h"

#include "mbed.h"

MOTOR::MOTOR(PinName D1, PinName D2, PinName pwm)
    :D1_(D1), D2_(D2), pwm_(pwm)
{
    D1_.write(0);
    D2_.write(0);
    pwm_.write(0);
}

void MOTOR::Dir(dire mode, uint8_t pwm)
{
    D1_.write((char)mode & 0x01);
    D1_.write((char)mode & 0x02);
    pwm_.write((float)(pwm / 100.0));
}

void MOTOR::Dir(dire mode)
{
    D1_.write((char)mode & 0x01);
    D1_.write((char)mode & 0x02);
}

void MOTOR::PWM(uint8_t pwm)
{
    pwm_.write((float)(pwm / 100.0));
}