How to code Joysticks in Vexcode IQ Blocks?

So, I have a lot of code figured out to cod the controller to do specific functions when certain buttons are pushed, but in order for one program to work, I need to figure out how to manually code the joysticks rather than the typical way where vex does it for me. I don know how to make the joysticks do different functions when moved.


Here’s what I have so far, but I’m not entirely sure how the axes work. Is the greater than/less than 0 blocks going to work? I haven’t been able to test it yet.

The joystick axes work on value ranges from -100 to +100. For the D axis you want to use, all the way down is -100; 0 is dead center; all the way up is +100. Here is a more concise way to implement what you want:

21 PM

1 Like

The ‘forever’ loop makes the brain constantly monitor the current value of your variable ‘d’ and constantly updates the velocity for Motor1 with that value. If the value is positive, it spins the motor forward. But if the value is negative, it spins the motor in reverse (or you can think of it like the computer thinks of it, which is to spin the motor “forward” at a negative speed). :slight_smile:

The other routine simply monitors the input of the controller axis D and writes that value to your variable ‘d’, which is used by the forever loop.

So when the D stick is not being touched, the value of ‘d’ is 0. When you push the D stick half way up, the value is +50. All the way up is +100. Halfway down is -50. All the way down is -100. etc…

Make sense?

To help my students understand what is going on in their programs, I insist that they use the screen to constantly print out values that change, so they can see with their eyes what is happening in real time. In your case, I would suggest the following to help you “see” how the axes values work:

05 PM

1 Like

You could just do:




1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.