Created
April 27, 2021 02:18
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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