We currently just did a rebuild and I sadly have to say we have a competition this weekend. The competition isn’t the sad part, that would be that I’ve spent the past three days trying to figure out how I implement my goal in Robotc. These past few days have made me want to stick to building and driving.
Issue/Goal- Our robots arm is driven using 6 motors and uses a potentiometer to check the rotation of the axle. Our claw is similar, however it is run using 2 motors and another potentiometer. I want the arm to raise up when Button 8UXmtr2 is pressed. The arm would have to stop when the potentiometer reaches my value or when my driver releases Button8UXmtr2. I can’t seem to figure out how to get the code to continually check to see if the button is pressed. I plan to have Button8DXmtr2 move the arm down using the potentiometer and like wise with the claw using Buttons 7UXmtr2 & 7DXmtr2.
I have tried programming the arm to raise when the button is pressed, however it gets stuck in the loop and doesn’t check to see if the button has been released. Any help would be greatly appreciated. Below is my current code with autonomous removed to shorten things.
#pragma config(Sensor, in1, ArmControl, sensorPotentiometer)
#pragma config(Sensor, in2, ClawControl, sensorPotentiometer)
#pragma config(Sensor, dgtl1, LeftDrive, sensorQuadEncoder)
#pragma config(Sensor, dgtl3, RightDrive, sensorQuadEncoder)
#pragma config(Sensor, dgtl10, Red, sensorDigitalIn)
#pragma config(Sensor, dgtl11, Blue, sensorDigitalIn)
#pragma config(Sensor, dgtl12, Green, sensorDigitalIn)
#pragma config(Motor, port1, LBlue, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port2, LeftWhiteRed, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port3, DriveLeft_1, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port4, DriveLeft_2, tmotorServoContinuousRotation, openLoop)
#pragma config(Motor, port5, RightClaw, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port6, RightBlue, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port7, RightWhiteRed, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, DriveRight_1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port9, DriveRight_2, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port10, LeftClaw, tmotorVex269_HBridge, openLoop, reversed)
#pragma platform(VEX2)
#pragma competitionControl(Competition)
#pragma autonomousDuration(15)
#pragma userControlDuration(105)
#include "Vex_Competition_Includes.c"
void pre_auton()
{
bStopTasksBetweenModes = true;
}
task autonomous()
{
AutonomousCodePlaceholderForTesting();
}
void ArmUp() // Remote 2
{
if(vexRT[Btn8UXmtr2] == 1 && SensorValue[in1] <= 2800)
{
motor[port1] = 127;
motor[port2] = 127;
motor[port6] = 127;
motor[port7] = 127;
}
wait10Msec(5);
}
void ArmDown() // Remote 2
{
if(vexRT[Btn8DXmtr2] == 1 && SensorValue[in1] >= 500)
{
motor[port1] = -127;
motor[port2] = -127;
motor[port6] = -127;
motor[port7] = -127;
}
wait10Msec(5);
}
void ClawOpen() // Remote 2
{
if(vexRT[Btn7DXmtr2] == 1 && SensorValue[in2] <= 1900)
{
motor[port5] = 127;
motor[port10] = 127;
}
wait10Msec(5);
}
void ClawClose() // Remote 2
{
if(vexRT[Btn7UXmtr2] == 1 && SensorValue[in2] >= 550)
{
motor[port5] = -127;
motor[port10] = -127;
}
wait10Msec(5);
}
task usercontrol()
{
while (true)
{
motor[port8] = (vexRT[Ch2] + vexRT[Ch1])/2; // (y + x)/2
motor[port9] = (vexRT[Ch2] + vexRT[Ch1])/2; // (y + x)/2
motor[port3] = (vexRT[Ch2] - vexRT[Ch1])/2; // (y - x)/2
motor[port4] = (vexRT[Ch2] - vexRT[Ch1])/2; // (y - x)/2
while(vexRT[Btn8UXmtr2] == 1 && SensorValue[in1] <= 2800)
{
ArmUp();
}
while(vexRT[Btn8DXmtr2] == 1 && SensorValue[in1] >= 500)
{
ArmDown();
}
while(vexRT[Btn7DXmtr2] == 1 && SensorValue[in2] <= 1900)
{
ClawOpen();
}
while(vexRT[Btn7UXmtr2] == 1 && SensorValue[in2] >= 550)
{
ClawClose();
}
}
}