RobotC Gamepad Library

Controlling an NXT with a gamepad in RobotC isn’t too difficult, but it does require some more advanced programming techniques.  Most programmers end up creating some helper functions and variables that they copy and paste throughout their projects, and here is my “library”.


Gamepad Layout


//RobotC Joystick Helper Example Source
//    Created By:        Mike Moss
//    Modified On:       01/09/2013

//Joystick Helper Code
#include "joystick_helper.c"

//Our Program
task main()
    //Do Forever
        //Get Gamepad States

        //Move motor A with the X button on joystick 1

        //Move motor C with the up arrow on the dpad (0 is up, 2 is right, 4 is down, etc...)

        //Move motor B based on the Y axis on the left thumb stick
        //    of joystick 2 with a deadzone of 15

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>