Miya Miyagawa
/
NRP2020_main
Outher...Miura Souta
Motor/Motor.cpp
- Committer:
- M_souta
- Date:
- 2020-01-21
- Revision:
- 1:5b0303768126
- Parent:
- 0:db8d4af513c0
- Child:
- 2:32d2cd7d744b
File content as of revision 1:5b0303768126:
#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_.period_us(50); // 20kHz pwm_.write(0); } void MOTOR::Dir(dire mode, uint8_t pwm) { D1_.write((char)mode & 0x01); D2_.write((char)mode & 0x02); pwm_.write((float)(pwm / 255.0)); } void MOTOR::Dir(dire mode) { D1_.write((char)mode & 0x01); D2_.write((char)mode & 0x02); } void MOTOR::PWM(uint8_t pwm) { pwm_.write((float)(pwm / 255.0)); }