Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Clawbot IQ Joystick sample program
#pragma config(Motor, port1, leftMotor, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port6, clawMotor, tmotorVex269, openLoop, reversed)
#pragma config(Motor, port7, armMotor, tmotorVex393, openLoop, reversed)
#pragma config(Motor, port10, rightMotor, tmotorVex393, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
task main ()
{
while(1 == 1)
{
//Use joystick Channel 2 for forward and backward movement
//Use joystick Channel 1 for left and right movement
motor[leftMotor] = (vexRT[Ch2] + vexRT[Ch1])/2; // (y + x)/2
motor[rightMotor] = (vexRT[Ch2] - vexRT[Ch1])/2; // (y - x)/2
// Raise, lower or do not move arm using buttons 5U and 5D
if(vexRT[Btn5U] == 1) //When button 5U is pressed:
{
motor[armMotor] = 127; //Raise arm at full speed
}
else if(vexRT[Btn5D] == 1) //If 5U is not pressed and 5D is pressed:
{
motor[armMotor] = -127; //Lower arm at full speed
}
else //Otherwise:
{
motor[armMotor] = 0; //Stop the arm.
}
// Open, close or do not more claw using buttons 6U and 6D
if(vexRT[Btn6U] == 1) //When button 6U is pressed:
{
motor[clawMotor] = 127; //Close gripper at full speed
}
else if(vexRT[Btn6D] == 1) //If 6U us not pressed and 6D is pressed:
{
motor[clawMotor] = -127; //Open the gripper at full speed
}
else //Otherwise:
{
motor[clawMotor] = 0; //Stop the gripper
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.