Hi. We are a rookie team and we are going to a competition tomorrow. We waited until the last minute to do our code and we do not understand why it does not work. We basically tried to code it so that the arm would lift up and down, but when it hit the top, a bumper switch would prevent it from moving up further. The arm can go down, but it won’t go up regardless of whether the bumper switch was hit. When we comment out the bumper switch part of the code the arm moves fine. Help would be greatly appreciated. Our code is attached below.
#pragma config(Sensor, dgtl1, topBumper, sensorTouch)
#pragma config(Motor, port1, frontLeftDrive, tmotorVex393TurboSpeed_HBridge, openLoop)
#pragma config(Motor, port2, clawdump, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port3, farleftDump, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port4, leftInDump, tmotorVex393TurboSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port5, rightTopDump, tmotorVex393TurboSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port6, rightBottomDump, tmotorVex393TurboSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port7, rightInDump, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port8, backLeftDrive, tmotorVex393TurboSpeed_MC29, openLoop)
#pragma config(Motor, port9, frontRightDrive, tmotorVex393TurboSpeed_MC29, openLoop, reversed)
#pragma config(Motor, port10, backRightDrive, 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()
{
while (true)
{
motor[backLeftDrive] = motor[frontLeftDrive] = vexRT[Ch3] + vexRT[Ch1]; //drive left
motor[backRightDrive] = motor[frontRightDrive] = vexRT[Ch3] - vexRT[Ch1]; //drive right
if(getJoystickValue(Btn5D) == true)
{
motor[clawdump]= 60;
}
else if (getJoystickValue(Btn5U) == true)
{
motor[clawdump] = -60;
}
else
{
motor[clawdump] = 0;
}
if(getJoystickValue(Btn6U) == 1 && SensorValue(topBumper) == 0)
{
motor[farleftDump] = motor[leftInDump] = motor[rightBottomDump]
= motor[rightTopDump] = motor[rightInDump]= -100;
}
else if(getJoystickValue(Btn6D) == 1)
{
motor[farleftDump] = motor[leftInDump] = motor[rightBottomDump]//revive dump
= motor[rightTopDump] = motor[rightInDump]= 100;
}
else
{
motor[farleftDump]= motor[leftInDump] = motor[rightBottomDump]//kill dump
= motor[rightTopDump] = motor[rightInDump]= 0;
}
}
}