-
-
Notifications
You must be signed in to change notification settings - Fork 4
Motor
Noah Zemlin edited this page Oct 21, 2018
·
4 revisions
The Motor class represents physical motors.
Example code to create a motor and send output.
Motor motorA = new Motor();
motorA.begin(4, 5, 3); //Initalize motor on digital pins 4 and 5, with PWM pin 3 as enable
motorA.output(0.5); //Output half of max speed to the motor.
Default constructor.
Initalizes a 2 pin motor
Motor motor = new Motor();
motor.begin(3,5); //Initalizes the motor on PWM pins 3 and 5
Initalizes a 3 pin motor
Motor motor = new Motor();
motor.begin(4,5,3); //Initalizes the motor on digital pins 4 and 5, and PWM pin 3.
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 = new Motor();
motor.begin(4,5,3); //Initalizes the motor on digital pins 4 and 5, and PWM pin 3.
motor.setDefaultOnZero(LOW); //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 motorA = new Motor();
motorA.begin(4, 5, 3); //Initalize motor on digital pins 4 and 5, with PWM pin 3 as enable
motorA.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 motorA = new Motor();
motorA.begin(4, 5, 3); //Initalize motor on digital pins 4 and 5, with PWM pin 3 as enable
motorA.outputBool(LOW); //Output LOW to both digital pins 4 and 5