void usercontrol(void) {
// User control code here, inside the loop
while (1) {
Left_Base.setVelocity(100,percent);
Right_Base.setVelocity(100,percent);
intake.setVelocity(100,percent);
High_stackets.setVelocity(100,percent);
// Deadband stops the motors when Axis values are close to zero.
int deadband = 5;
// Get the velocity percentage of the left motor. (Axis3)
int leftSideSpeed = Controller1.Axis3.position() / 2;
// Get the velocity percentage of the right motor. (Axis2)
int rightSideSpeed = Controller1.Axis2.position() / 2;
// Set the speed of the left motor. If the value is less than the deadband,
// set it to zero.
if (abs(leftSideSpeed) < deadband) {
// Set the speed to zero.
Left_Base.setVelocity(0, percent);
} else {
// Set the speed to leftMotorSpeed
Left_Base.setVelocity(leftSideSpeed, percent);
}
// Set the speed of the right motor. If the value is less than the deadband,
// set it to zero.
if (abs(rightSideSpeed) < deadband) {
// Set the speed to zero
Right_Base.setVelocity(0, percent);
} else {
// Set the speed to rightMotorSpeed
Right_Base.setVelocity(rightSideSpeed, percent);
}
// Spin both motors in the forward direction.
Left_Base.spin(forward);
Right_Base.spin(forward);
// If the Button L1 is hold will spin the intake forwod or will not spin
if(Controller1.ButtonL1.pressing()){
intake.spin(forward);}
else{
intake.stop();
}
// If the button L2 is hold will spin the intake reverse or will not spin
if(Controller1.ButtonL2.pressing()){
intake.spin(reverse);}
else{
intake.stop();}
//If the Button R1 is hold wiil spin the higher stackes or will spin
if(Controller1.ButtonR1.pressing()){
High_stackets.spin(reverse);}
else{
High_stackets.stop();
}
//Of the Pistons
digital_out digl=digital_out(Brain.ThreeWirePort.A);
int main(){
int count=0;
while (1) {
if(Controller1.ButtonA.pressed()){
dig1.set(true);
}
else{
dig1.set(false);
}
wait(10,msec);
}
// ........................................................................
// Insert user code here. This is where you use the joystick values to
// update your motors, etc.
// ........................................................................
wait(20, msec); // Sleep the task for a short amount of time to
// prevent wasted resources.
}
//
// Main will set up the competition functions and callbacks.
//
int main() {
// Set up callbacks for autonomous and driver control periods.
Competition.autonomous(autonomous);
Competition.drivercontrol(usercontrol);
// Run the pre-autonomous function.
pre_auton();
// Prevent main from exiting with an infinite loop.
while (true) {
wait(100, msec);
}
}
look more closely, I see errors. perhaps try formatting it a bit better.
3 Likes
i looked at the code I was not able fix the errors.
is said the "int main () "{ " " also the final bracket
why do you have “main” buried inside usercontrol ?
2 Likes
because it will mess with the “dig1”
is for the Pneumatic Pistons of the fire and retracting the pistons.
You have two main functions? And one of them is inside another function. Try defining pneumatics globally.
1 Like