December 1, 2009

Lego-X Tutorial #1: Controlling you NXT with a joystick

Hello again everyone!  MAN!  I'm on a posting spree!  Anyway, this is Lego-X's first Tutorial!  Today, I'm going to show you how to move your robot with a Joystick (a Wii Remote too (coming soon)).

First you need: GlovePIE, then a Bluetooth remote, a Joystick, then your NXT Robot (I used Tri Bot).
Install GlovePIE and the Bluetoothe Remote onto your computer.
Then, type up this little code in GlovePIE:
Key.Up = Joystick1.y < -0.9
Key.Down = Joystick1.y > 0.9
Key.Left = Joystick1.x < -0.9
Key.Right = JoyStick1.x > 0.9
Key.T = Joystick1.Pov1Up
Key.G = Joystick1.Pov1Down
Key.W = JoyStick1.Button1
Key.S = JoyStick.Button2
Key.Y = JoyStick1.Pov1Right
Key.H = JoyStick1.Pov1Left
(This is for the Logitech Extreme 3D PRO Joystick BTW) (This is also assuming that your using the default keys on the Bluetooth Remote)
Then, connect your robot to the Remote, run the script on GlovePIE, then, click the Remote window.  It should work very nicely.
How did you like the first Lego-X tutorial?  Coming soon, a tutorial on how to control you NXT with the Wii Remote!
P.S. I have uploaded the GlovePIE Source to Google Code HERE

No comments:

Post a Comment