Outher...Miura Souta

Dependencies:   mbed MCP23017

Committer:
M_souta
Date:
Tue Jan 21 11:10:33 2020 +0000
Revision:
1:5b0303768126
Parent:
0:db8d4af513c0
Child:
2:32d2cd7d744b
lll

Who changed what in which revision?

UserRevisionLine numberNew contents of line
M_souta 0:db8d4af513c0 1 #include "Motor.h"
M_souta 0:db8d4af513c0 2
M_souta 0:db8d4af513c0 3 #include "mbed.h"
M_souta 0:db8d4af513c0 4
M_souta 0:db8d4af513c0 5 MOTOR::MOTOR(PinName D1, PinName D2, PinName pwm)
M_souta 0:db8d4af513c0 6 :D1_(D1), D2_(D2), pwm_(pwm)
M_souta 0:db8d4af513c0 7 {
M_souta 0:db8d4af513c0 8 D1_.write(0);
M_souta 0:db8d4af513c0 9 D2_.write(0);
M_souta 1:5b0303768126 10 pwm_.period_us(50); // 20kHz
M_souta 0:db8d4af513c0 11 pwm_.write(0);
M_souta 0:db8d4af513c0 12 }
M_souta 0:db8d4af513c0 13
M_souta 0:db8d4af513c0 14 void MOTOR::Dir(dire mode, uint8_t pwm)
M_souta 0:db8d4af513c0 15 {
M_souta 0:db8d4af513c0 16 D1_.write((char)mode & 0x01);
M_souta 1:5b0303768126 17 D2_.write((char)mode & 0x02);
M_souta 1:5b0303768126 18 pwm_.write((float)(pwm / 255.0));
M_souta 0:db8d4af513c0 19 }
M_souta 0:db8d4af513c0 20
M_souta 0:db8d4af513c0 21 void MOTOR::Dir(dire mode)
M_souta 0:db8d4af513c0 22 {
M_souta 0:db8d4af513c0 23 D1_.write((char)mode & 0x01);
M_souta 1:5b0303768126 24 D2_.write((char)mode & 0x02);
M_souta 0:db8d4af513c0 25 }
M_souta 0:db8d4af513c0 26
M_souta 0:db8d4af513c0 27 void MOTOR::PWM(uint8_t pwm)
M_souta 0:db8d4af513c0 28 {
M_souta 1:5b0303768126 29 pwm_.write((float)(pwm / 255.0));
M_souta 0:db8d4af513c0 30 }