I just need help to know how to code movement for this. I have two motor groups, front (green cartrage, and back ( red cartrade). My team wants it binded to the stick axies. Thank you for helping my team.
Welcome to the Forums! Question: do you want to slow the green motors down to match the speed of the red motors (to keep them from fighting and eventually only being a little faster than the red), or do you have gearing to make them the same speed? As for programming, there are some past threads that I believe answer this question pretty well, just hit the search button in the top left and type away
3 Likes
Don’t know if you found how to make it work yet but I wrote some basic code with comments to explain each line I added. Don’t forget to reverse your left or right motors depending on how your robot is oriented.
/*----------------------------------------------------------------------------*/
/* */
/* Module: main.cpp */
/* Author: C:\Users\rylan */
/* Created: Mon Oct 17 2022 */
/* Description: V5 project */
/* */
/*----------------------------------------------------------------------------*/
// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name] [Type] [Port(s)]
// FrontMotorLeft motor 1
// FrontMotorRight motor 2
// BackMotorLeft motor 3
// BackMotorRight motor 4
// Controller1 controller
// ---- END VEXCODE CONFIGURED DEVICES ----
#include "vex.h"
//IDK why but you need this part for user and auton control to work seperate in the same code
competition Competition;
using namespace vex;
//groups the left motors in a group for easier usage
motor_group Left_Drive = motor_group(FrontMotorLeft, BackMotorLeft);
//groups the right motors in a group for easier usage
motor_group Right_Drive = motor_group(FrontMotorRight, BackMotorRight);
//Declares the user control function
void User(){
//loops the user control so it keeps running
while(true){
//Moves the left side with up and down movement of the left thumbstick
Left_Drive.spin(forward, Controller1.Axis3.position(percent), percent);
//Moves the right side with up and down movement of the right thumbstick
Right_Drive.spin(forward, Controller1.Axis2.position(percent), percent);
}
}
//Declares the Auton control function
void Autonomous(){
//You can put future autonomous code in here, don't need it to drive though
}
int main() {
// Initializing Robot Configuration. DO NOT REMOVE!
vexcodeInit();
//Tells the brain where to find the user code
Competition.drivercontrol(User);
//Tells the brain where to find the auton code
Competition.autonomous(Autonomous);
}
2 Likes