ROBOTC.net forums
http://www.robotc.net/forums/

Program Won't function on robot.
http://www.robotc.net/forums/viewtopic.php?f=11&t=9665
Page 1 of 1

Author:  patriot9098 [ Wed Oct 29, 2014 10:18 am ]
Post subject:  Program Won't function on robot.

I wrote this program in robotC with multiple functions. The robot will drive fine. However, I can't get my arms, my shift motor, or any other buttons to perform their functions. Is it just something incredibly simple I'm missing? Or are the function calls incorrect? Any help would be greatly appreciated.
Apologies for the long Code.

#pragma config(Sensor, in5, leftLineFollower, sensorLineFollower)
#pragma config(Sensor, in6, centerLineFollower, sensorLineFollower)
#pragma config(Sensor, in7, rightLineFollower, sensorLineFollower)
#pragma config(Sensor, in8, gyro, sensorGyro)
#pragma config(Sensor, in3, armPot, sensorPotentiometer)
#pragma config(Sensor, dgtl1, rightEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, leftEncoder, sensorQuadEncoder)
#pragma config(Sensor, dgtl6, frontLimit, sensorTouch)
#pragma config(Sensor, dgtl8, sonarSensor, sensorSONAR_cm)
#pragma config(Motor, port2, rightMotor, tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor, port3, leftMotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port6, armMotor, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port4, shiftMotor, tomotorServoContinuousRotation,openLoop)

//Code automatically generated by 'ROBOTC' configuration wizard !!*//

//allows me to call function so that it zeroes encoders and motors
void sensorZero()
{
motor[armMotor] = 0;
motor[leftMotor] = 0;
motor[rightMotor] = 0;
motor[shiftMotor] = 0;
SensorValue[leftEncoder] = 0;
SensorValue[rightEncoder] = 0;
}

//allows me to shift gears
void motorShift(string GearChange)
{
if (GearChange == "GearUp")
{
motor[shiftMotor] = 127;
wait1Msec (400);
}
else if(GearChange == "GearDown")
{
motor[shiftMotor] = -127;
wait1Msec(400);
}
sensorZero();
}

//zero the sensors and motors


//turn left and right tank turn
void tankTurn(string strDirection)
{
while (strDirection == "Right" || SensorValue[rightEncoder] < 540)
{
motor[rightMotor] = 63;
motor[leftMotor] = -63;
}

while (strDirection == "Left" || SensorValue[leftEncoder] < 540)
{

motor[rightMotor] = -63;
motor[leftMotor] = 63;

}
sensorZero();
}



task main()
{
//these strings allow me to call the functions
string gearDown = "GearDown";
string gearUp = "GearUp";

string Rght = "Right";
string Left = "Left";

while(1 == 1)
{
//driving motor control
motor[rightMotor] = vexRT[Ch3];
motor[leftMotor] = vexRT[Ch2];

}
sensorZero();

//when 6u pressed, move arm motor up at full speed
while(vexRT[Btn6U] == 1)
{
motor[armMotor] = 65;

}
sensorZero();

//if btn6d pressed, move arm motor down at full speed
while (vexRT[Btn6D] == 1)
{
motor[armMotor] = -65;

}

//else statement removed


while (vexRT[Btn8L] == 1) //This code Turns the robot TankLeft On button8L press
{
tankTurn(Left);
}

while(vexRT[Btn8R] == 1) //This code turns the robot TankRight on button5u press
{
tankTurn(Rght);
}

while(vexRT[Btn8D] == 1)
{
tankTurn(Rght);
tankTurn(Rght);
}


while(vexRT[Btn5D] == 1)
{
motorShift(gearDown);
}

while(vexRT[Btn5D] == 1)
{
motorShift(gearUp);
}

}

Author:  patriot9098 [ Wed Oct 29, 2014 10:45 am ]
Post subject:  Re: Program Won't function on robot.

Alright I fixed this, turns out it was stuck on the motor while loop. Took whole program in a while, and now it works fine. [Delete Thread]

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/