I am new to vexcode text and need just some general help, tips, anything!
All help is greatly accepted!
P.S. I just need mostly autonomous help.
Here is the code
/----------------------------------------------------------------------------/
/* /
/ Module: main.cpp /
/ Author: VEX /
/ Created: Thu Sep 26 2019 /
/ Description: Competition Template /
/ /
/----------------------------------------------------------------------------*/
// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// FLMotor motor 1
// FRMotor motor 10
// RLMotor motor 11
// RRMotor motor 20
// Tray motor 5
// ClawUpDown motor 6
// Claw motor 7
// Controller1 controller
// ---- END VEXCODE CONFIGURED DEVICES ----
#include “vex.h”
using namespace vex;
// A global instance of competition
competition Competition;
// define your global instances of motors and other devices here
/---------------------------------------------------------------------------/
/* Pre-Autonomous Functions /
/ /
/ You may want to perform some actions before the competition starts. /
/ Do them in the following function. You must return from this function /
/ or the autonomous and usercontrol tasks will not be started. This /
/ function is only called once after the V5 has been powered on and /
/ not every time that the robot is disabled. /
/---------------------------------------------------------------------------*/
void pre_auton(void) {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
// All activities that occur before the competition starts
// Example: clearing encoders, setting servo positions, …
}
/---------------------------------------------------------------------------/
/* /
/ Autonomous Task /
/ /
/ This task is used to control your robot during the autonomous phase of /
/ a VEX Competition. /
/ /
/ You must modify the code to add your own robot specific commands here. /
/---------------------------------------------------------------------------*/
void autonomous(void) {
// …
// Insert autonomous user code here.
// …
}
/---------------------------------------------------------------------------/
/* /
/ User Control Task /
/ /
/ This task is used to control your robot during the user control phase of /
/ a VEX Competition. /
/ /
/ You must modify the code to add your own robot specific commands here. /
/---------------------------------------------------------------------------*/
void usercontrol(void) {
// User control code here, inside the loop
//Use these variables to set the speed of the arm and claw.
int armSpeedPCT = 100;
int slowClawSpeedPCT = 100;
int chuteSpeedPCT = 70;
Brain.Screen.print(“SUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCC”);
Brain.Screen.newLine();
Brain.Screen.print(“SUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCC”);
Brain.Screen.newLine();
Brain.Screen.print(“SUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCC”);
Brain.Screen.newLine();
Brain.Screen.print(“SUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCC”);
Brain.Screen.newLine();
Brain.Screen.print(“SUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCC”);
Brain.Screen.newLine();
Brain.Screen.print(“SUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCC”);
Brain.Screen.newLine();
Brain.Screen.print(“SUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCC”);
Brain.Screen.newLine();
Brain.Screen.print(“SUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCC”);
Brain.Screen.newLine();
Brain.Screen.print(“SUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCC”);
Brain.Screen.newLine();
Brain.Screen.print(“SUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCC”);
Brain.Screen.newLine();
Brain.Screen.print(“SUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCC”);
Brain.Screen.newLine();
Brain.Screen.print(“SUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCCSUCC”);
//Create an infinite loop so that the program can pull remote control values every iteration.
//This loop causes the program to run forever.
while(1) {
//Drive Control
//Set the left and right motor to spin forward using the controller Axis values as the velocity value.
FRMotor.spin(vex::directionType::fwd, (Controller1.Axis2.value()), vex::velocityUnits::pct);
FLMotor.spin(vex::directionType::fwd, (Controller1.Axis3.value()), vex::velocityUnits::pct);
RRMotor.spin(vex::directionType::fwd, (Controller1.Axis2.value()), vex::velocityUnits::pct);
RLMotor.spin(vex::directionType::fwd, (Controller1.Axis3.value()), vex::velocityUnits::pct);
//ArmMotor
if(Controller1.ButtonL1.pressing()) { //If button L1 is pressed...
//...Spin the arm motor forward.
Tray.spin(vex::directionType::fwd, armSpeedPCT, vex::velocityUnits::pct);
}
else if(Controller1.ButtonL2.pressing()) { //If the L2 button is pressed...
//...Spin the arm motor backward.
Tray.spin(vex::directionType::rev, armSpeedPCT, vex::velocityUnits::pct);
}
else { //If the the L1 or L2 button is not pressed...
//...Stop the arm motor.
Tray.stop(vex::brakeType::brake);
}
//LeftIntake Control
if(Controller1.ButtonR1.pressing()) { //If the R1 button is pressed...
//...Spin the LeftIntake forward.
Claw.spin(vex::directionType::fwd, slowClawSpeedPCT, vex::velocityUnits::pct);
}
else if(Controller1.ButtonR2.pressing()) { //If the R2 button is pressed...
//...Spin the LeftIntake backward.
Claw.spin(vex::directionType::rev, slowClawSpeedPCT, vex::velocityUnits::pct);
}
else { //If the R1 or R2 button are not pressed...
//...Stop the LeftIntake.
Claw.stop(vex::brakeType::brake);
}
//ChutePush Control
if(Controller1.ButtonUp.pressing()) { //If the Up button is pressed...
//...Spin the ChuteMotor forward.
ClawUpDown.spin(vex::directionType::fwd, chuteSpeedPCT, vex::velocityUnits::pct);
}
else if(Controller1.ButtonDown.pressing()) { //If the Down button is pressed...
//...Spin the ChuteMotor backward.
ClawUpDown.spin(vex::directionType::rev, chuteSpeedPCT, vex::velocityUnits::pct);
}
else { //If the Up or Down button are not pressed...
//...Stop the ChutePush.
ClawUpDown.stop(vex::brakeType::brake);
}
vex::task::sleep(20); //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);
}
}