 | Quote: #pragma config(Hubs, S1, HTMotor, HTServo, HTMotor, none) #pragma config(Sensor, S1, , sensorI2CMuxController) #pragma config(Sensor, S2, touch, sensorNone) #pragma config(Sensor, S3, light, sensorNone) #pragma config(Sensor, S4, IR, sensorHiTechnicIRSeeker600) #pragma config(Motor, motorA, Claw, tmotorNXT, PIDControl) #pragma config(Motor, motorB, Arm, tmotorNXT, PIDControl, encoder) #pragma config(Motor, mtr_S1_C1_1, driveL, tmotorTetrix, openLoop, reversed) #pragma config(Motor, mtr_S1_C1_2, driveR, tmotorTetrix, openLoop) #pragma config(Motor, mtr_S1_C3_1, Lift1, tmotorTetrix, openLoop, reversed) #pragma config(Motor, mtr_S1_C3_2, Lift2, tmotorTetrix, openLoop) #pragma config(Servo, srvo_S1_C2_1, Susan, tServoStandard) #pragma config(Servo, srvo_S1_C2_2, Bar, tServoContinuousRotation) #pragma config(Servo, srvo_S1_C2_3, servo3, tServoNone) #pragma config(Servo, srvo_S1_C2_4, servo4, tServoNone) #pragma config(Servo, srvo_S1_C2_5, servo5, tServoNone) #pragma config(Servo, srvo_S1_C2_6, servo6, tServoNone) //*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#include "JoystickDriver.c" //Joystick's In Program + bluetooth messages. void joystickstart (int joy1_y2, int joy1_x2) { servo[Susan] = 140; // Puts Servo in its neutral return; } task main() { bFloatDuringInactiveMotorPWM = false; waitForStart(); // wait for start of tele-op phase int b = 10;// Prevents twitching int w = -10; int a = ServoValue [Susan];// Assigns a variable to servo-+ int z = ServoValue [Bar]; servoChangeRate[Bar] = 6; servoChangeRate[Susan] = 5;// Slows servo down to prevent servo from burning out or break. while(1 == 1) // Repeats forever. { getJoystickSettings(joystick); // Gets Joystick settings if((joy1_y2 > 15) && (joy1_x2 < 40) && (joy1_x2 > -40))//joy1_ 2 Driver joysztick on the right. { motor[driveL] = joy1_y2; motor[driveR] = joy1_y2; } else { motor[driveR] = 0; motor[driveL] = 0; // Says if you have joystick backward then the robot moves backward }
if((joy1_y2 < 50) && (joy1_x2 > -40) && (joy1_x2 < 40)) { motor[driveR] = -joy1_y2; motor[driveL] = joy1_y2; } else { motor[driveR] = 0; motor[driveL] = 0; // If you have joystick to the right then the robot will go forward otherwise it'll stop. } if((joy1_y2 < -50) && (joy1_x2 > -40) && (joy1_x2 < 40)) { motor[driveR] = joy1_y2; motor[driveL] = -joy1_y2; } else { motor[driveR] = 0; motor[driveL] = 0; // If you have joystick to the right then the robot will go forward otherwise it'll stop. } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Drivers Remote is all done being programmed. Everything from this point is going to be the Attatchment Controller:// ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if ((joystick.joy2_y2) > b) { servo[Bar] = z + 5;// Means that the power will be related to how far you push aslong as its > 10 } else { servo[Bar] = z; } if ((joystick.joy2_y2) > w) { servo[Bar] = z - 5;// Means that the power will be related to how far you push aslong as its > 10 } else { servo[Bar] = z; }
if(abs(joystick.joy2_y1) > b) { motor[Arm] = joystick.joy2_y1; }
if (joy2Btn(04) == 1) { servo[Susan] = a + 5; // Adds 5 to the servo value allowing us to move the servo where we want it to. }
if (joy2Btn(07) == 1) { servo[Susan] = a - 5 > 0; // Subtracts 5 from servo value letting us go the opposite way. } if (joy1_TopHat == 0) { motor[Lift1] = 75; motor[Lift2] = 75; // Lift goes up at 75 power } if (joy1_TopHat == 4) { motor[Lift1] = -75; motor[Lift2] = -75;// Lift goes down at 75 } } } |  |