The arm on my robot only goes up and i’m not quite sure what is wrong with the touch sensors could someone look at the code and fix it.
Here is the code
#pragma config(Sensor, dgtl1, au, sensorTouch)
#pragma config(Sensor, dgtl2, ad, sensorTouch)
#pragma config(Motor, port1, lift, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port2, a1, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port3, a2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port4, a3, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port5, a4, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port6, d1, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port7, d2, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port8, d3, tmotorVex393_MC29, openLoop, reversed)
#pragma config(Motor, port9, d4, tmotorVex393_MC29, openLoop)
#pragma config(Motor, port10, hd, tmotorVex393_HBridge, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
#pragma platform(VEX)
//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)
#include “Vex_Competition_Includes.c” //Main competition background code…do not modify!
// You may want to perform some actions before the competition starts. Do them in the
// following function.
void pre_auton()
{
// Set bStopTasksBetweenModes to false if you want to keep user created tasks running between
// Autonomous and Tele-Op modes. You will need to manage all user created tasks if set to false.
bStopTasksBetweenModes = true;
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, ...
}
task autonomous()
{
// …
// Insert user code here.
// …
AutonomousCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
}
task usercontrol()
{
while (true)
{
motor[d1] = vexRT[Ch2];
motor[d3] = vexRT[Ch2];
motor[d2] = vexRT[Ch3];
motor[d4] = vexRT[Ch3];
}
if(vexRT[Btn5U] == 1)
{
motor[hd] = 127;
}
if(vexRT[Btn5D] == 1)
{
motor[hd] = -127;
}
if(vexRT[Btn5U] == 0)
{
motor[hd] = 0;
}
if(vexRT[Btn5D] == 0)
{
motor[hd] = 0;
}
if(vexRT[Btn6D] == 1)
{
motor[a1] = 127;
motor[a2] = 127;
motor[a3] = 127;
motor[a4] = 127;
}
if(vexRT[Btn6D] == 0)
{
motor[a1] = 0;
motor[a2] = 0;
motor[a3] = 0;
motor[a4] = 0;
}
if(vexRT[Btn8L] == 1)
{
motor[a1] = -127;
motor[a2] = -127;
motor[a3] = -127;
motor[a4] = -127;
}
//safety button
if(vexRT[Btn7L] == 1)
{
motor[a1] = 0;
motor[a2] = 0;
motor[a3] = 0;
motor[a4] = 0;
motor[d1] = 0;
motor[d2] = 0;
motor[d3] = 0;
motor[d4] = 0;
motor[hd] = 0;
motor[lift] = 0;
}
while(SensorValue(ad) == 1) // Loop while robot's lower sensor is pressed in
{
motor[a1] = 0;
motor[a2] = 0;
motor[a3] = 0;
motor[a4] = 0;
}
while(SensorValue(au) == 1) // Loop while robot’s upper sensor is pressed in(add in pneumatic pistons when we get some)
{
motor[a1] = -127;
motor[a2] = -127;
motor[a3] = -127;
motor[a4] = -127;
}
UserControlCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
}