pros::adi::Ultrasonic class

Constructors, destructors, conversion operators

Ultrasonic(std::uint8_t adi_port_ping, std::uint8_t adi_port_echo) explicit
Configures a set of ADI ports to act as an Ultrasonic sensor.
Ultrasonic(ext_adi_port_tuple_t port_tuple) explicit
Configures a set of ADI ports on an adi_expander to act as an Ultrasonic sensor.

Public functions

std::int32_t get_value() const
Gets the current ultrasonic sensor value in centimeters.
ext_adi_port_tuple_t get_port() const
Gets the port of the sensor.

Function documentation

ext_adi_port_tuple_t pros::adi::Ultrasonic::get_port() const

Gets the port of the sensor.

Returns returns a tuple of integer ports.

Example

#define DIGITAL_SENSOR_PORT 1 // 'A'

void initialize() {
  pros::adi::AnalogIn sensor (DIGITAL_SENSOR_PORT);
  
     // Getting values from the tuple using std::get<index> 
     int sensorSmartPort = std::get<0>(sensor.get_port()); // First value
  int sensorAdiPort = std::get<1>(sensor.get_port()); // Second value

     // Prints the first and second value from the port tuple (The Adi Port. The first value is the Smart Port)
  printf("Sensor Smart Port: %d\n", sensorSmartPort);
  printf("Sensor Adi Port: %d\n", sensorAdiPort);   
}