#include "vex.h"
using namespace vex;
competition Competition;
brain brain;
controller controller1;
motor right1(PORT1, gearSetting::ratio18_1, false);
motor right2(PORT2, gearSetting::ratio18_1, false);
motor left1(PORT3, gearSetting::ratio18_1, false);
motor left2(PORT4, gearSetting::ratio18_1, false);
motor intake(PORT5, gearSetting::ratio18_1, false);
motor lift1(PORT6, gearSetting::ratio18_1, false);
motor lift2(PORT6, gearSetting::ratio18_1, true);
void pre_auton(void) {
vexcodeInit();
}
void autonomous(void) {
}
void usercontrol(void) {
while (1) {
right1.spin(directionType::fwd, (controller1.Axis3.value() + controller1.Axis4.value()), velocityUnits::pct);
right2.spin(directionType::fwd, (controller1.Axis3.value() + controller1.Axis4.value()), velocityUnits::pct);
left1.spin(directionType::fwd, (controller1.Axis3.value() + controller1.Axis4.value()), velocityUnits::pct);
left2.spin(directionType::fwd, (controller1.Axis3.value() + controller1.Axis4.value()), velocityUnits::pct);
if(controller1.ButtonR2.pressing()){
intake.spin(directionType::fwd, 100, velocityUnits::pct);
lift1.spin(directionType::fwd, 100, velocityUnits::pct);
lift2.spin(directionType::fwd, 100, velocityUnits::pct);
}
else if(controller1.ButtonL2.pressing()){
intake.spin(directionType::rev, 100, velocityUnits::pct);
lift1.spin(directionType::rev, 100, velocityUnits::pct);
lift2.spin(directionType::rev, 100, velocityUnits::pct);
}
else{
intake.stop(brakeType::hold);
lift1.stop(brakeType::hold);
lift2.stop(brakeType::hold);
}
if(controller1.ButtonR1.pressing()){
lift1.spin(directionType::fwd, 100, velocityUnits::pct);
lift2.spin(directionType::fwd, 100, velocityUnits::pct);
}
else if(controller1.ButtonL1.pressing()){
lift1.spin(directionType::rev, 100, velocityUnits::pct);
lift2.spin(directionType::rev, 100, velocityUnits::pct);
}
else{
lift1.stop(brakeType::hold);
lift2.stop(brakeType::hold);
}
}
int main(){
Competition.autonomous(autonomous);
Competition.drivercontrol(usercontrol);
pre_auton();
while (true) {
wait(100, msec);
}
}
}
I’ve been trying to figure out what i did wrong can anyone help me out?
Well, you can’t really run both lift motors off of the same port. I’d fix that first.
i have that set up like that so i can change them to how i need them to be later
Say more about this please. We are all used to the 1 named motor per port paridigm, exception being Y connector on Cortex.
Is this using the competition template? If so, I believe that it is extraneous to add the devices to underneath the competition Competition; global instance. That could lead to redefinition of global instances, as this should already be in robot-config.cpp, leading to the issues in the program.
That’s true. @Forbidlake60338 could you add a .zip of your code rather than just the text from main.cpp? Thanks!
I’m going to change the ports to make it easier so plug everything when we’re ready to plug it all in to test it in but i don’t know how everything is going on the bot yet cause I’ve been sick.
Ok, so by using the names you have only one place to change them, the config area, to move the motors and sensors from port to port. You should just have one name per port to help keep it clear.
thank you everyone i got it work and i wouldn’t have been able to do it without your help.