back to FEHMotor
Description
Once a motor object is declared, this function allows the user to set the power of the motor as a percentage. The function takes 1 floating point input with a linear range from -100 to 100. The sign of the number corresponds to the polarity of the voltage sent to the motor. A positive value turns the motor one direction, and the LED on the Proteus by the motor port will appear green. A negative value turns the motor the other direction, and the LED on the Proteus by the motor port will appear red. A value of zero corresponds to the motor being off.
Syntax
.SetPercent( percent )
Parameters
percent
: Float value that represents the power level of a motor with a range from -100.0% to 100.0%
Returns
None.
Examples
#include <FEHMotor.h> int main(void) { //declares a motor on motor port 0 FEHMotor right_motor(FEHMotor::Motor0, 9.0); //set right motor power full speed forward right_motor.SetPercent(100.); //set right motor power full speed backward right_motor.SetPercent(-100.); }