Im trying to make a code using the GPS sensor that can drive to a specific coordinate using if statements. I've only done the X portion, and it works, but I'm looking for how I can stop checking the X statement, and move on to the Y:
void driveTo (int xPos, int yPos) {
printPos();
if(xPos > 0){
Drivetrain.turnToHeading(90, degrees);
while (GPS14.xPosition(mm) < xPos) {
Drivetrain.drive(forward);
}
Drivetrain.stop();
}
if(xPos < 0){
Drivetrain.turnToHeading(-90, degrees);
while (GPS14.xPosition(mm) > xPos) {
Drivetrain.drive(forward);
}
Drivetrain.stop();
}
}
int main() {
driveTo (0, 0);
}`