 | Code: #pragma config(Hubs, S1, HTMotor, HTMotor, HTMotor, HTServo) #pragma config(Hubs, S3, HTMotor, none, none, none) #pragma config(Sensor, S1, , sensorI2CMuxController) #pragma config(Sensor, S2, SEEKER, sensorHiTechnicIRSeeker1200) #pragma config(Sensor, S3, , sensorI2CMuxController) #pragma config(Motor, motorA, leftnxt, tmotorNXT, openLoop) #pragma config(Motor, motorB, rightnxt, tmotorNXT, openLoop) #pragma config(Motor, motorC, , tmotorNXT, openLoop) #pragma config(Motor, mtr_S1_C1_1, left, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S1_C1_2, left2, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S1_C2_1, right, tmotorTetrix, openLoop, reversed) #pragma config(Motor, mtr_S1_C2_2, right2, tmotorTetrix, openLoop, reversed) #pragma config(Motor, mtr_S1_C3_1, arm, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S1_C3_2, linear, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S3_C1_1, light, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S3_C1_2, motorK, tmotorTetrix, openLoop) #pragma config(Servo, srvo_S1_C4_1, tilt, tServoStandard) #pragma config(Servo, srvo_S1_C4_2, servo2, tServoNone) #pragma config(Servo, srvo_S1_C4_3, servo3, tServoNone) #pragma config(Servo, srvo_S1_C4_4, servo4, tServoNone) #pragma config(Servo, srvo_S1_C4_5, servo5, tServoNone) #pragma config(Servo, srvo_S1_C4_6, servo6, tServoNone) #pragma config(SrvoPosition, Position01, 131, 128, 128, 128, 128, 226, 128, 128) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c"
task main() { while (1 == 1) { getJoystickSettings(joystick);
if (joystick.joy2_y2 < 10 && joystick.joy2_y2 > -10) /* Makes left side wheels move in tandem and same speed */ { // Makes motors = joystick move // but if at 10 or negative 10 stop motor[right] = 0; motor[right2] = 0; // just states if joystick = 10 or -10 motor = 0
} else { motor[right] = joystick.joy2_y2; motor[right2] = joystick.joy2_y2; // if it is above 10 or -10 then the motor power = the joystick. }
if (joystick.joy2_y1 < 10 && joystick.joy2_y1 > -10) /* Makes left side wheels move in tandem and same speed */ { // Makes motors = joystick move // but if at 10 or negative 10 stop motor[left] = 0; motor[left2] = 0; // joystick if 10 or -10 = motor power = 0
} else { motor[left] = joystick.joy2_y1; // if it is above 10 or -10 then the motor power = the joystick. motor[left2] = joystick.joy2_y1;
} while (joy2Btn(6) == 1 ) { motor[right] = joystick.joy2_y2/3; motor[right2] = joystick.joy2_y2/3; motor[left] = joystick.joy2_y1/3; motor[left2] = joystick.joy2_y1/3; } if (joystick.joy1_y1 < 5 && joystick.joy1_y1 > -5) //motor = 0 if at 5 or -5 { motor[arm] = 0;
} else { motor[arm] = joystick.joy1_y1/3;
} { if(joy1Btn(1) == 1) // If Joy1-Button2 is pressed: { motor[arm] = -4; // ring is Grabbed // Can use the debugger to help find these positions }
// Infinite loop: { if(joy1Btn(9) == 1) // If Joy1-Button2 is pressed: { servo[tilt] = 45; // ring is Grabbed // Can use the debugger to help find these positions } { if(joy1Btn(4) == 1) // If Joy1-Button2 is pressed: { servo[tilt] = 1; // ring is Grabbed // Can use the debugger to help find these positions }
{ if(joy1Btn(2) == 1) // If Joy1-Button2 is pressed: { servo[tilt] = 217; // ring is Grabbed // Can use the debugger to help find these positions } { if(joy1Btn(3) == 1) // Open position us Joy1btn 3 // if button 3 is pressed { servo[tilt] = 95;
}
}
if(joy1Btn(7) == 1) // If Joy1-Button7is pressed: { motor[linear] = -100; // Turn Motor linear at full power } else // If Joy1-Button7 is NOT pressed: { motor[linear] = 0; // Turn linear Off } if(joy1Btn(7)) { motor[linear] = -100; // linear is run at a power level of -100. arm down wait1Msec(100); }
if(joy1Btn(5) == 1) // If Joy1-Button7is pressed: { motor[linear] = -25; // Turn Motor linear at full power } else // If Joy1-Button7 is NOT pressed: { motor[linear] = 0; // Turn linear Off } if(joy1Btn(5)) { motor[linear] = -25; // linear is run at a power level of -100. arm down wait1Msec(100); }
if(joy1Btn(6) == 1) // If Joy1-Button7is pressed: { motor[linear] = 25; // Turn Motor linear at full power } else // If Joy1-Button7 is NOT pressed: { motor[linear] = 0; // Turn linear Off } if(joy1Btn(6)) { motor[linear] = 25; // linear is run at a power level of -100. arm down wait1Msec(100); } if(joy1Btn(8) == 1) // If Joy1-Button8 is pressed: { motor[linear] = 100; // Turn Motor linear On at full power } else // If Joy1-Button8 is NOT pressed: { motor[linear] = 0; // Turn linear Off } if(joy1Btn(8)) { motor[linear] = 100; // linear is run at a power level of 100. wait1Msec(100); }
if(joy2Btn(5) == 1) // If Joy1-Button8 is pressed: { int count = 0; while(count < 10) { motor[light] = 100; // linear is run at a power level of 100. wait1Msec(250); motor[light] = 0; // linear is run at a power level of 100. wait1Msec(250); count = count + 1; }
}
}}}}}} |  |