So we built a robot that is like a scissor lift kind-of thing. with the v5 kit. We want to program it to lift up and down using the V5 controller. The problem is that it just won’t work. We’re able to more the robot back and forth with the controller. It can turn left and right as well.
To make it work, both motors on the left and right has to move together but I have no idea how to that since the drivetrain was the only one that could move with both the motors at the same time. I decided to add in a separate motor for each one: the left one and the right one then press both buttons assigned to each motor at the same time instead. It still doesn’t work though.
Also: a suggestion on how to slow down the speed of the robot when using the controller is appreciated.
This is kinda what the robot looks like (without the wheels). :
When it’s pushed, the height raises from the current level. We want to move it up/down with the controller
This is the controller in the “devices”
Separating the lift and the drivetrain into two different controller devices (in programming app) doesn’t work either. (meaning : adding two controllers in devices, one is solely for the lift and the other one for drivetrain. Both aren’t using the same buttons either)
You need to add your own programming to control both motors for a lift at the same time from a single button or joystick.
Welcome to VEX Forum! I think the problem is that the two motors aren’t moving at the same time. In order to do that, you’ll need a little complicated code. Also, since blocks has its limits, I suggest using the VEXcode V5 Pro. The coding language is C++ and it might take some time getting used to it, but it can do much more than blocks such as PID or Odometry.
What would that code be? Or what would it look like?
void armUp(){
while (Controller1.ButtonR1.pressing() == true) {
LeftArm.spin(reverse);
RightArm.spin(forward);
if (Controller1.ButtonR1.pressing() == false){
LeftArm.setStopping(brake);
RightArm.setStopping(brake);
LeftArm.stop();
RightArm.stop();}
}
}
This is the code that I’m using, but it really depends on your device configuration and your driver.
I would recommend something like this:
while(true){ /*infinite loop to allow for drive*/
if (Controller1.ButtonR1.pressing() == true){ /*this allows for when you press R1 for the lift to all ways lift*/
LeftSideLift.spin(forward);
RightSideLift.spin(forward);
}
else if (Controller1.ButtonR2.pressing() == true){/*this allows for when you press R2 for the lift to all ways go down*/
LeftSideLift.spin(reverse);
RightSideLift.spin(reverse);
}
else{ /* This allows for the lift to not move if the user is not pressing anything*/
LeftSideLift.stop(brake);
RightSideLift.stop(brake);
}
}
Thank you so much, I tried adapting it but do you know why the last symbol always has an error? Sorry I’m not familiar with the codes
Like the last “{” is always an error. If i delete it then whatever is before that { is an error too
Double-check that all the brackets are closed and make sure that you used brackets only where you need them.
you shouldn’t have multiple while(true)
loops.
also all your while loops except the last are missing their closing bracket.
put all the code you want to constantly run inside just one while(true)
loop and make sure every {
has a }
add a } after line 32 and remove delete what is on line 33 right now. That should fix everything
You don’t need to modify the code. It should work as is since the spin function with no rotational parameter is a non-blocking function.
he doesnt have brackets… doesnt matter what the code says, it wont work without brackets
Without even examine the code, I would recommend taking the advice of the member of a world championship team. They probably know what they’re doing