Will this program work for Spin Up?

This should let the driver press X at any time and the robot would turn to face the starting point. I am going to evolve this so that it turns to face the high goal at any point of time in the game. Please give me tips on this, because I am relatively new to C++

/*
/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       C:\Users\100039046                                        */
/*    Created:      Fri May 06 2022                                           */
/*    Description:  V5 project                                                */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name]               [Type]        [Port(s)]
// Drivetrain           drivetrain    1, 2, 3, 4, 6   
// Vision5              vision        5               
// Controller1          controller                    
// ---- END VEXCODE CONFIGURED DEVICES ----

#include "vex.h"

using namespace vex;

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();
  DrivetrainGPS.setOrigin(0, 0, mm);
  if (Controller1.ButtonA.pressing()){
double xPos=DrivetrainGPS.xPosition(mm) ;
double yPos=DrivetrainGPS.yPosition(mm) ;
double slope=yPos/xPos;
double angle =(round(100*((1/tan(slope * M_PI / 180)))/100));
Drivetrain.turnToRotation(angle, degrees); 
  };
}

*/

This post was flagged by the community and is temporarily hidden.

3 Likes

Don’t know how to. 20 char

The forums use something called “Markdown Formatting.” Google it for more information if you’re interested. In the future, please enclose your code in three back ticks ( ` ) on the lines before and after it. You can copy & paste these or the key is directly under the escape key on standard keyboards.
In the editor it will look like this:
```
/* Your Code Here */
```
In the formatted text it will look like this:

/* Your Code Here */

It would be helpful if you could edit your post to use this formatting as it assists in reading your code.

2 Likes

Thanks. I will try to remember this in the future.