toshi mura
/
NRP2020_main
gjyrjyykkudt
Diff: Motor/Motor.cpp
- Revision:
- 0:db8d4af513c0
- Child:
- 1:5b0303768126
diff -r 000000000000 -r db8d4af513c0 Motor/Motor.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Motor/Motor.cpp Mon Jan 20 08:46:24 2020 +0000 @@ -0,0 +1,29 @@ +#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)); +} \ No newline at end of file