Skip to content

Instantly share code, notes, and snippets.

@ringodin
Created April 27, 2021 02:18
Show Gist options
  • Save ringodin/131d6dda2a097ef17195817e7e267392 to your computer and use it in GitHub Desktop.
Save ringodin/131d6dda2a097ef17195817e7e267392 to your computer and use it in GitHub Desktop.
using VEXCode with v5 robot, and the rangefinder to turn right then left with a counter
#include "vex.h"
using namespace vex;
int main() {
int counter = 0;
Brain.Screen.print(counter);
Drivetrain.setDriveVelocity(30, percent);
wait(1,seconds);
while(true){
Drivetrain.drive(forward);
if (RangeFinderA.distance(mm) < 300 && counter == 0) {
Drivetrain.stop();
wait(0.5,seconds);
Drivetrain.turnFor(right, 90, degrees);
wait(0.5,seconds);
counter++;
Brain.Screen.newLine();
Brain.Screen.print(counter);
}
if (RangeFinderA.distance(mm) < 300 && counter == 1) {
Drivetrain.stop();
wait(0.5,seconds);
Drivetrain.turnFor(left, 90, degrees);
wait(0.5,seconds);
counter++;
Brain.Screen.newLine();
Brain.Screen.print(counter);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment