-
Notifications
You must be signed in to change notification settings - Fork 0
RobotC Quick Reference
lexrobotics1 edited this page Oct 15, 2013
·
4 revisions
//drive motors
motor[motorName] = 100; //power ranges from -100 (full reverse) to 100 (full forwards). 0 is stopped
//standard servo
servo[servoName] = 128; //set position of servo, ranging from 0 (0 degrees) to 255 (180 degrees)`
//continuous rotation servo
servo[servoName] = 128; //set speed of servo, ranging from 0 (full reverse) to 255 (full forwards). 128 is stopped
//NXT display
eraseDisplay(); //erases display... #duh
nxtDisplayCenteredTextLine(lineNum, "This is a number: %d", numberToPrint); //prints out centered text on the corresponding line. See here for more on formatting: http://www.robotc.net/support/nxt/MindstormsWebHelp/index.htm#page=nxt_functions/display/Display.htm
//joystick
#include "JoystickDriver.c" //include this library to use controller methods
getJoystickSettings(joystick); //store controller input in joystick struct (joystick automatically exists, no need to create it)
/***fist controller***/
//leftmost joystick
joystick.joy1_x1; //x axis
joystick.joy1_y1; //y axis
//rightmost joystick
joystick.joy1_x2; //x axis
joystick.joy1_y2; //y axis
//buttons
joy1Btn(num); //returns boolean of whether or not button is pressed on joystick (int num is number labeled on button)
/***second controller***/
//leftmost joystick
joystick.joy2_y1; //x axis
joystick.joy2_x1; //y axis
//rightmost joystick
joystick.joy2_x2; //x axis
joystick.joy2_y2; //y axis
//buttons
joy2Btn(num); //returns boolean of whether or not button is pressed on joystick (int num is number labeled on button)