Robot only moves forward when running code

The controls on the joystick work just fine with the regular Drive mode, but the issue happens when I try to run a file.

If I don’t add a controller and I only add just the drivetrain, the joysticks will just not move at all. However, when I do add a controller and set it to Left Arcade for example, it will only ever move forward no matter what direction I point the joystick in. I’ve remade new files and redone the code many times but it still does not work.
I was under the impression that I wouldn’t have to, but does this mean I have to code for each joystick? In that case, how would I be able to do that?

It is worth mentioning that I am completely new to VEX and robotics this year and am still unfamiliar with the programs.

Thank you for your help.

Welcome to the forums @aiko!
I think the best way to look into this one is if you could upload your VEXcode V5 file here so that we can take a look at the configuration and see what is going on.

3 Likes

If you post your code here we can help you out. :slight_smile:

test 2.v5blocks (7.8 KB)

Does this work? Here is a screenshot if it doesn’t.

You need to code it so when the joystick goes forward, the motors will turn. that code is just setting how fast it is. (Also does not need to be in a forever loop)

I’ve posted it in the replies, thank you for your help.

Try this. You need to have it coded so the controller will actually control it. Or else nothing will happen.

2 Likes

I don’t normally code with blocks so if it doesn’t work let me know.

I saw in tutorials that if you use this setting, you don’t need to code any blocks for that, how would I code it so I can use the left joystick for the left side and vice versa like the default controls on Drive?

Thanks for the tip on the forever loop!

1 Like

thats just setting up what the buttons do, you still have to code it

Got it, I’m not able to try it with the robot right now but I’ll definitely do so next time. Thank you for your help :slight_smile:

1 Like

Of course! Happy to help!

1 Like

Thanks for posting the code.

The issue here is there is a conflict between what your controller is telling the drivetrain to do, and what the block code is telling it to do.

When you move your controller joysticks, they send a velocity value from 0 to 100% to the drivetrain. You can actually think of it as -100% (full reverse) to zero (stop) to +100% full forwards, and everything in between.

So you move the joystick to lets say -50% so the robot should go backwards, but then your block code instantly says “no no, you will go to 50%”

So in this case, for the drivetrain, you do not need any blocks for velocity at all. The controller will handle that for you.

When you are using the digital buttons on the controller, that is different. Digital buttons just tell the motor to spin, but not how fast. It is set to 50% by default, but your code can set a motor velocity for a motor controlled by a digital button (e.g. motor 20 in your example) and next time you press the button, it will spin at that speed.

4 Likes

I use text, but this is basically what I was getting at. (other than the elses) but it’s the same idea. You register the button (in this case the joysticks) and then code what they do.

That is a whole world of conflict, assuming the if/else code is in a loop. If it isn’t it won’t really do anything.
If it is, it’ll give some interesting results. Most of the time, the controller configured mode will win the conflict, but the buttons would have some undesired behaviours.

3 Likes

I dont have any issues with it soo… It works perfectly.

The code as written there will do next to nothing since the if statements are only evaluated once taking a small fraction of a second, and then never again, giving the appearance of nothing ever happening. Of course, the controller configuration stuff will work just fine and the robot will drive.

But let’s not derail this thread any further and leave it for the OP’s issue.

1 Like

I see, thank you! This was very helpful in understanding how the controls work.

1 Like