-
-
Notifications
You must be signed in to change notification settings - Fork 4
Motor
Noah Zemlin edited this page Jun 17, 2019
·
4 revisions
The Motor class represents physical motors.
Example code to create a motor and send output.
Motor motor;
motor.begin(4, 5, 3); //Initalize motor on digital pins 4 and 5, with PWM pin 3 as enable
motor.output(0.5); //Output half of max speed to the motor.
Default constructor.
Initalizes a 2 pin motor
Motor motor;
motor.begin(3,5); //Initalizes the motor on PWM pins 3 and 5
Initalizes a 3 pin motor
Motor motor;
motor.begin(4,5,3); //Initalizes the motor on digital pins 4 and 5, and PWM pin 3.
Reverses the direction of a motor by swapping the two input pins (in1pin and in1pin).
Motor motor;
motor.begin(4,5,3).reverse(); //Initalizes the motor on digital pins 4 and 5, and PWM pin 3. It then reverses the direction.
Set the default signal to send to in1pin and in2pin on 0 speed. By default, this is set to HIGH.
Used for turning on brake or float. See Motor Controller datasheet for brake and float control logic.
Motor motor;
motor.begin(4,5,3).setDefaultOnZero(LOW); //Initalizes the motor on digital pins 4 and 5, and PWM pin 3. When the speed is set to 0, LOW will be applied to both digital pins 3 and 4.
Output a speed to the motor, between -1 and 1.
Speed of 0 outputs LOW or HIGH to both in1pin and in2pin based on setDefaultOnZero(). The default is HIGH.
Motor motor;
motor.begin(4, 5, 3); //Initalize motor on digital pins 4 and 5, with PWM pin 3 as enable
motor.output(0.5); //Output half of max speed to the motor.
Sends LOW or HIGH to both in1pin and in2pin.
Used for turning on brake or float. See Motor Controller datasheet for brake and float control logic.
Motor motor;
motor.begin(4, 5, 3); //Initalize motor on digital pins 4 and 5, with PWM pin 3 as enable
motor.outputBool(LOW); //Output LOW to both digital pins 4 and 5