Created
May 4, 2021 06:36
-
-
Save ringodin/d9ae14ca475e28735ed4bd86bf958007 to your computer and use it in GitHub Desktop.
Use an idle-loop to allow your robot to "hang out" at a particular task until a condition is met.
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
// ---------------------------------------------------------------------------- | |
// | |
// Project: 3-Wire Rangefinder Sensing | |
// Description: This example will show all of the available commands | |
// for using the 3-Wire Rangefinder Sensor | |
// Configuration: V5 Speedbot (Drivetrain 2-motor, No Gyro) | |
// Rangefinder in 3-Wire Ports A B | |
// | |
// ---------------------------------------------------------------------------- | |
#include "vex.h" | |
using namespace vex; | |
// Begin project code | |
int main() { | |
Drivetrain.setDriveVelocity(30, percent); | |
wait(0.2,seconds); | |
Drivetrain.drive(forward); | |
Brain.Screen.clearScreen(); | |
Brain.Screen.setCursor(1,1); | |
Brain.Screen.print("Found Object?: %s", RangeFinderA.foundObject() ? "TRUE" : "FALSE"); | |
Brain.Screen.newLine(); | |
Brain.Screen.print("Distance - Inches: %.2f", RangeFinderA.distance(inches)); | |
Brain.Screen.newLine(); | |
Brain.Screen.print("Distance - MM: %.2f", RangeFinderA.distance(mm)); | |
Brain.Screen.newLine(); | |
//A brief delay to allow text to be printed without distortion or tearing | |
wait(50, msec); | |
while (RangeFinderA.distance(mm) > 300) { | |
wait(50, msec); | |
} | |
Drivetrain.stop(); | |
wait(0.5,seconds); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment