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 #include "mbed.h" 00003 00004 00005 // ================================================================== 00006 // Constructor 00007 // ================================================================== 00008 Motor::Motor(PinName pwm, PinName fwd, PinName rev): 00009 _pwm(pwm), _fwd(fwd), _rev(rev) { 00010 00011 // Set initial condition of PWM 00012 _pwm.period(0.001); 00013 _pwm = 0; 00014 00015 // Initial condition of output enables 00016 _fwd = 0; 00017 _rev = 0; 00018 00019 } 00020 00021 00022 // ================================================================== 00023 // Set the motor speed and direction 00024 // ================================================================== 00025 void Motor::speed(float speed) { 00026 _fwd = (speed > 0.0); 00027 _rev = (speed < 0.0); 00028 _pwm = abs(speed); 00029 } 00030 00031 00032
Generated on Thu Jul 14 2022 03:22:15 by
1.7.2