I am new to C++ and do not know the jargon. How do I work the ultrasound? Specifically, when coding pros::(what goes here for the ultrasound)
? I am also trying to get the distance traveled to be calculated and shown on the controller. Is that possible? If so, does anyone have advice for how I can do it?
https://pros.cs.purdue.edu/v5/api/cpp/adi.html#pros-adiultrasonic
Here’s the PROS API page for the ultrasonics. Under the example tab is some code that actually accomplishes some of what you are trying to do.
void opcontrol() {
pros::ADIUltrasonic sensor (PORT_PING, PORT_ECHO);
while (true) {
// Print the distance read by the ultrasonic
std::cout << "Distance: " << sensor.get_value();
pros::delay(10);
}
}
The main difference is it just is printing the distance, but it would be easy to adapt that to printing to the controller.
I don’t use PROS much but I’m assuming you would use controller::print to print to the controller (https://pros.cs.purdue.edu/v5/api/cpp/misc.html#print)
3 Likes