Making motor spin in vex code block

How do i get my motor to spin forward when I press L1 on the controller. I am using vex code v5 blocks. I am very confused.

@scott15709, I believe there are multiple example code files that VEX provides included with VexCode (File → Open Examples). You can also refer to the Vex command reference, linked below:

https://help.vexcodingstudio.com/#block

If you have more specific questions about your code, feel free to post it in this thread, many people would be happy to help fix it with you.

1 Like

What you’re actually asking is very simple…

Both of the following blocks would do the trick.

image

You probably wan the motor to stop if you let go of the button, or to stop as some other time. You will need to account for that.

In the controller setup you can quickly attach motors to pairs of buttons. Do not also code for these motors as that may cause unexpected results.

image

1 Like

You could also reverse the motor direction when you set up the device. Several ways to skin this cat.

Take a look at the “Controller Button” example project inside of VEXcode V5 Blocks. It uses a controller button event to trigger a motor and then stopped the motor when the controller button is released. Here’s a snippet:

31%20AM

1 Like

Thank yall for helping I got it to work. I got the code to work and realized a very idiotic mistake. I had the motor code in the wrong port lol.

We’ve all done that. :crazy_face::sweat_smile:

2 Likes

Not sure if this is helpful or not, but we do have a STEM Lab (one each for IQ and V5) that covers programming the Controller. Here’s a link to the V5 STEM Lab: https://education.vex.com/parent-wrapper.php?id=clawbot-controller-v5

We’d certainly be open to making more STEM Labs focused on programming with the Controller. Let us know.

1 Like