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 // H-Bridge Motor Control 00002 // Copyright (c) 2009 sford 00003 // Released under the MIT License: http://mbed.org/license/mit 00004 00005 #include "Motor.h" 00006 00007 #include "mbed.h" 00008 00009 Motor::Motor(PinName pwm, PinName fwd, PinName rev) : _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 void Motor::speed(float speed) { 00021 _fwd = (speed > 0.0); 00022 _rev = (speed < 0.0); 00023 _pwm = abs(speed); 00024 }
Generated on Mon Jul 18 2022 00:17:18 by
1.7.2