We’re having trouble getting the Motor.Spin command to work.
These two lines of code work great by themselves. Using these two lines, we can start the program and run our motors as expected by changing vertical axes 2 and 3 on our Controller.
LeftMotor.spin(vex::directionType::fwd, Controller1.Axis3.value(), vex::velocityUnits::pct);
RightMotor.spin(vex::directionType::fwd, Controller1.Axis2.value(), vex::velocityUnits::pct);
The problem comes when we attempt to add two more lines to make similar assignments to the horizontal axes 4 and 1 on our Controller, For some reason when we add these two additional lines, all joystick changes on our Controller stop working . The motors may move a little, but they are slow, sporadic, and jumpy - almost as if we are somehow sending conflicting commands.
LeftMotor.spin(vex::directionType::fwd, Controller1.Axis4.value(), vex::velocityUnits::pct);
RightMotor.spin(vex::directionType::fwd, Controller1.Axis1.value(), vex::velocityUnits::pct);
When we remove these second two lines, the problem goes away and our original vertical axes assignments work again as expected.
Thank you for any thoughts and suggestions on this!
What are you trying to do with these lines of code? You are essentially telling the motors to use the value from 3, then 4, then 3, then 4 and so on. Have you looked at motor code examples on the forum?
Our ultimate goal is to be able to move our robot during driver control as follows:
Move the robot forward by pushing both joysticks up (so that the left joystick controls the left motor and the right joystick controls the right motor).
Move the robot backward by pushing both joysticks down (again, so that the left joystick controls the left motor and the right joystick controls the right motor separately).
Turn the robot either left or right by having one joystick up and the other down (or vise versa).
Turn the robot left or right (with very little velocity, primarily for aligning the direction of the robot) by using the horizontal/vertical axes on one joystick at a time.
Yes, we’ve been looking at code examples on the forum. We’re new to V5 programming and have had trouble finding comparable examples to this.
Thanks so much!
Because that is what you’re doing. “Left motor, do what axis 3 says. Left motor, do what axis 4 says.” Your control logic needs to happen before you give a value to