Hey,
I was coding a tank control and am only known to code for tank control/drive like this:
#include “vex.h”
using namespace vex;
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// Deadband stops the motors when Axis values are close to zero.
int deadband = 5;
while (true) {
// Get the velocity percentage of the left motor. (Axis3)
int leftSideSpeed = Controller1.Axis3.position();
// Get the velocity percentage of the right motor. (Axis2)
int rightSideSpeed = Controller1.Axis2.position();
// Set the speed of the left motor. If the value is less than the deadband,
// set it to zero.
if (abs(leftSideSpeed) < deadband) {
// Set the speed to zero.
DriveLeftFront.setVelocity(0, percent);
DriveLeftBack.setVelocity(0, percent);
} else {
// Set the speed to leftMotorSpeed
DriveLeftFront.setVelocity(leftSideSpeed, percent);
DriveLeftBack.setVelocity(leftSideSpeed, percent);
}
// Set the speed of the right motor. If the value is less than the deadband,
// set it to zero.
if (abs(rightSideSpeed) < deadband) {
// Set the speed to zero
DriveRightFront.setVelocity(0, percent);
DriveRightBack.setVelocity(0, percent);
} else {
// Set the speed to rightMotorSpeed
DriveRightFront.setVelocity(rightSideSpeed, percent);
DriveRightBack.setVelocity(rightSideSpeed, percent);
}
// Spin both motors in the forward direction.
DriveLeftFront.spin(forward);
DriveLeftBack.spin(forward);
DriveRightFront.spin(forward);
DriveRightBack.spin(forward);
wait(25, msec);
}
}
this code does work, but I want to lower the velocity or speed as the robot goes too fast. I would appreciate if anyone could tell me how I can do this. Thanks for your help as usual.