Driver control code not working

Hello, I would like to code an arcade drive (I believe that’s what its called), with the left joystick as forward and backward, but no matter what I change the code in the driver control, it is stuck in some weird tank drive. Also, when I try to code my intake in driver control, nothing happens. Can anyone help please?

void opcontrol() {
    // controller
    // loop to continuously update motors


    while (true) {
        // get joystick positions
        int leftY = controller.get_analog(pros::E_CONTROLLER_ANALOG_LEFT_Y);
        int rightX = controller.get_analog(pros::E_CONTROLLER_ANALOG_RIGHT_Y);
        chassis.tank(leftY,rightX);
    }
	if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_R1))
			LowIntake.move(127);
		HighIntake.move(127);

    

	if(controller.get_digital(pros::E_CONTROLLER_DIGITAL_R2))
			LowIntake.move(127);
		HighIntake.move(127);


    pros::delay(10);
}

The while loop only runs the tank drive, move the closing brace for the while loop.

3 Likes

How exactly do I do that? Im sorry, but I am new to coding

Hm, perhaps PROS is the wrong environment then.

You need all the code, including the delay at the end, inside of the

while (true) {

loop

Ok, that makes sense, the only problem Im encountering is that the code doesn’t download into the brain for some reason, thank you though!

To build experience I would recommend using VexCode blocks to get started. Simply use the config to design your own arcade drive for a chassis.
https://codev5.vex.com/

  1. Start a new project or look at the available examples under the file menu.

  2. Build your configuration under the devices on the right.

  3. Try creating code with blocks on the left.

  4. After you have made a small demo program - not too complicated - use the Code Viewer button to convert the project to c++ text.

Now you can review the code that was generated, learn from it, and apply it to your own projects. It will give you a much better understanding. The other option would be to paste all of the code into ChatGPT and have it explain how the code works. The important thing is for you to learn and understand - don’t have AI code it because it will leave you in a bad spot if you don’t understand it yourself.

Good luck!

Yeah, I used block code first, but it was hard because our school has a new starting up program, so there is no one to look at/learn from. I wanted to try to implement PID and ODOM, like the top teams, but didn’t know how, so I jumped from Blockcode to Pros. Maybe I should have done what you have here