i am having problems with the push button not working along with other things really not working verry well with the code can someone rewrite it for me and just kinda explain what you changed so i can learn for next time
thanks!
#pragma config(Sensor, dgtl1, au, sensorTouch)
#pragma config(Sensor, dgtl2, ad, sensorTouch)
#pragma config(Sensor, dgtl7, solenoid, sensorDigitalOut)
#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];
motor[a1] = (vexRT[Btn5U] - vexRT[Btn5D]) * 127;
motor[a2] = (vexRT[Btn5U] - vexRT[Btn5D]) * 127;
motor[a3] = (vexRT[Btn5U] - vexRT[Btn5D]) * 127;
motor[a4] = (vexRT[Btn5U] - vexRT[Btn5D]) * 127;
while(SensorValue(au) == 1) // Loop while robot's upper sensor is pressed in(add in pneumatic pistons when we get some)
{
SensorValue[solenoid] = 1;
sleep(50);
motor[a1] = 0;
motor[a2] = 0;
motor[a3] = 0;
motor[a4] = 0;
{
if(vexRT[Btn8D] == 1) // If button 6U (upper right shoulder button) is pressed:
{
SensorValue[solenoid] = 1; // ...activate the solenoid.
}
else // If button 6U (upper right shoulder button) is NOT pressed:
{
SensorValue[solenoid] = 0; // ..deactivate the solenoid.
}
}
}
}
}