LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Use joystick to control a graphic

Okay, I really need some help here. I need to use a joystick to control an X on the front panel. Basically i have a box on the front panel and Will have a crosshare or x centered in that box. I need to use a joystick to move that crosshare anywhere in the box, and know what the coordinates of that x are. Anyone have any suggestions?
Thanks,
0 Kudos
Message 1 of 8
(3,555 Views)
The input devices palette contains a VI you can use to get the axis position of the joystick. Once you have the axis position, you can do some simple grapical programming to display your X on a picture control. If the built in VIs don't work for you, you can write your own by making calls to the windows API. There are lots of examples on using joysticks with LV, using both the built in VIs and API calls, here are a few:

32 button joystick vi with 6 axis control
JoystickData.vi
Motion Control with USB Joystick
Reading a Joystick's Status

Regards,
Ryan K.
0 Kudos
Message 2 of 8
(3,549 Views)
Thank you for the reply. The first example you have listed is mine actually 🙂 I am comfortable with the joystick part of this, I just dont know how to integrate graphics into labview. I will look at these other examples and see if i can figure something out. Any help with api's or other methods would be greatly appreciated. Thanks,
Dave
0 Kudos
Message 3 of 8
(3,528 Views)
Good deal, you've already got the tricky part then. Displaying the crosshair in a picture control just requires
some simple graphical programming (although I used a circle instead of a crosshair because I'm lazy). I've attached a quick example, I haven't tested it with a joystick since I don't have one, but as long as you can get the x and y axis values from your joystick and you know the maximum possible value for them, you should be able to plug it right in. Let me know if you have any questions.

Ryan K.
Message 4 of 8
(3,525 Views)
great, let me give this a shot, ill let you know,
Dave
0 Kudos
Message 5 of 8
(3,520 Views)
Dont have 7.1 yet, I have 7. Any way you can save the vi as an older version for me? Thanks,
Dave
0 Kudos
Message 6 of 8
(3,517 Views)
Try this one.

Ryan
Message 7 of 8
(3,510 Views)
That is just what i needed. Thank you very much for your help.
0 Kudos
Message 8 of 8
(3,506 Views)