View unanswered posts | View active topics It is currently Fri Sep 20, 2019 4:09 am






Reply to topic  [ 2 posts ] 
Program Won't function on robot. 
Author Message
Rookie

Joined: Wed Oct 29, 2014 10:09 am
Posts: 2
Post 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);
}

}


Wed Oct 29, 2014 10:18 am
Profile
Rookie

Joined: Wed Oct 29, 2014 10:09 am
Posts: 2
Post 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]


Wed Oct 29, 2014 10:45 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.