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.
Motor.cpp
00001 #include "Motor.h" 00002 00003 Motor::Motor(PinName IN1, PinName IN2, PinName INH1, PinName INH2) 00004 : IN1_(IN1), IN2_(IN2), INH1_(INH1), INH2_(INH2) 00005 { 00006 INH1_=1; 00007 INH2_=1; 00008 IN1_.period_us(100); 00009 IN2_.period_us(100); 00010 } 00011 00012 void Motor::setSpeed_percent(float percent, float direction) 00013 { 00014 float duty = percent/100.0; 00015 if(duty>1.0) { 00016 duty=1.0; 00017 } else if(duty<0.0) { 00018 duty=0.0; 00019 } 00020 if(direction==FORWARD) { 00021 IN1_=duty; 00022 IN2_=0; 00023 } else { 00024 IN1_=0; 00025 IN2_=duty; 00026 00027 } 00028 } 00029
Generated on Wed Jul 13 2022 10:19:08 by
1.7.2