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.
Dependents: TI_TB6612FNG_SAMPLE
Moter.cpp
00001 #include "Moter.h" 00002 00003 Moter::Moter(PinName pwm, PinName in1, PinName in2):_pwm(pwm), _in1(in1), _in2(in2) 00004 { 00005 _in1 = 0; 00006 _in2 = 0; 00007 _pwm = 0.0; 00008 00009 _pwm.period(0.001); 00010 } 00011 00012 float Moter::speed(float speed) 00013 { 00014 if(speed > 0.0) { 00015 _pwm = speed; 00016 _in1 = 1; 00017 _in2 = 0; 00018 } else if(speed < 0.0) { 00019 _pwm = -speed; 00020 _in1 = 0; 00021 _in2 = 1; 00022 } else { 00023 _in1 = 1; 00024 _in2 = 1; 00025 } 00026 00027 return speed == 0 ? 0 : speed > 0 ? 1 : -1; 00028 }
Generated on Tue Jul 26 2022 06:59:37 by
1.7.2