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.
DCMotor.cpp
00001 #include "DCMotor.h" 00002 #include "mbed.h" 00003 00004 DCMotor::DCMotor(PinName PWMPin, PinName PinA, PinName PinB): 00005 _PWMPin(PWMPin), _PinA(PinA), _PinB(PinB) { 00006 00007 _PWMPin.period(0.001); 00008 _PWMPin = 0; 00009 00010 _PinA = 0; 00011 _PinB = 0; 00012 } 00013 00014 void DCMotor::driveIt(float perCent) { 00015 if (perCent > 0) { 00016 _PinA = 0; 00017 _PinB = 1; 00018 00019 } else { 00020 _PinA = 1; 00021 _PinB = 0; 00022 } 00023 _PWMPin = fabs(perCent/100); 00024 }
Generated on Sat Jul 23 2022 04:20:56 by
1.7.2