Hi. We are a new team having trouble coding a limit on how much our claw can move. It will not open at all when we run the following code:
#pragma config(I2C_Usage, I2C1, i2cSensors)
#pragma config(Sensor, dgtl1, ArmEncoder, sensorQuadEncoder)
#pragma config(Sensor, I2C_1, , sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Sensor, I2C_2, , sensorQuadEncoderOnI2CPort, , AutoAssign )
#pragma config(Motor, port1, backRightDrive, tmotorVex393TurboSpeed_HBridge, openLoop)
#pragma config(Motor, port2, rightClaw, tmotorVex393TurboSpeed_MC29, openLoop, encoderPort, I2C_2)
#pragma config(Motor, port3, leftClaw, tmotorVex393TurboSpeed_MC29, openLoop, reversed, encoderPort, I2C_1)
#pragma config(Motor, port4, farLeftDump, tmotorVex393TurboSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port5, InLeftDump, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port6, InRightDump, tmotorVex393TurboSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port7, farRightDump, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port8, frontRightDrive, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port9, backLeftDrive, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port10, frontLeftDrive, tmotorVex393TurboSpeed_HBridge, openLoop)
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//
#pragma platform(VEX2)
// Select Download method as "competition"
#pragma competitionControl(Competition)
//Main competition background code...do not modify!
#include "Vex_Competition_Includes.c"
void pre_auton()
{
}
task autonomous()
{
}
task usercontrol()
{
SensorValue[ArmEncoder]=0;
nMotorEncoder[rightClaw] = 0;
nMotorEncoder[leftClaw] = 0;
while (true)
{
motor[backLeftDrive] = motor[frontLeftDrive] = vexRT[Ch1] + vexRT[Ch3]; //drive left
motor[backRightDrive] = motor[frontRightDrive] = vexRT[Ch1] - vexRT[Ch3]; //drive right
if(getJoystickValue(Btn5U) == 1){
motor[leftClaw] = motor[rightClaw] = 127;
}
else if(getJoystickValue(Btn5D) == 1 && nMotorEncoder[leftClaw] << 200){
motor[leftClaw] = -127;
}
else if(getJoystickValue(Btn5D) == 1 && nMotorEncoder[rightClaw] << -200){
motor[rightClaw] = 0;
}
else if(getJoystickValue(Btn5D) == 1 && nMotorEncoder[leftClaw] >> 200){
motor[leftClaw] = 0;
}
else if(getJoystickValue(Btn5D) == 1 && nMotorEncoder[rightClaw] >> -200) {
motor[rightClaw] = 127;
}
else{
motor[leftClaw] = 0;
motor[rightClaw] = 0;
}
// if(getJoystickValue(Btn5D) == 1)
// {
// motor[rightClaw] = motor[leftClaw] = -100;
// }
// else if (getJoystickValue(Btn5U) == 1)
// {
// motor[rightClaw] = motor[leftClaw] = 100;
// }
//else
// {
// motor[rightClaw] = motor[leftClaw] = 10;
// }
if(getJoystickValue(Btn6U) == 1 && SensorValue[ArmEncoder] <= 110)
{
motor[farLeftDump] = motor[InLeftDump] = motor[farRightDump] = motor[InRightDump] = 100;
}
else if(getJoystickValue(Btn6D) == 1)
{
motor[farLeftDump] = motor[InLeftDump] = motor[farRightDump] = motor[InRightDump] = -50;
}
else if(SensorValue[ArmEncoder] <= 110)
{
motor[farLeftDump] = motor[InLeftDump] = motor[farRightDump] = motor[InRightDump] = 15;
}
else
{
motor[farLeftDump] = motor[InLeftDump] = motor[farRightDump] = motor[InRightDump] = 0;
}
}
}
We know it is not a problem with the sensors because they are not sending back values. Help is much appreciated. Thank you!