MOREbot_Library  1.3.2
Library to control the MOREbot base robot
Public Member Functions | List of all members
ultrasonic Class Reference

#include <MOREbot.h>

Public Member Functions

 ultrasonic (int trig, int echo)
 
float readDistance ()
 

Detailed Description

Ultrasonic class. Handles communicating with the ultrasonic module to determine distance to the nearest object.

Constructor & Destructor Documentation

◆ ultrasonic()

ultrasonic::ultrasonic ( int  trig,
int  echo 
)

Ultrasonic constructor. Saves the pins to communicate with the ultrasonic module.

Parameters
trigan integer. The pin on the arduino that the ultrasonic's trig pin is connected to.
echoan integer. The pin on the arduino that the ultrasonic's echo pin is connected to.

Member Function Documentation

◆ readDistance()

float ultrasonic::readDistance ( )

Function to get distance from the Ultrasonic. Activates the ultrasonic, reads the echo time, and processes that time into a distance in centimeters.

Returns
float distance to the closest object in centimeters.

The documentation for this class was generated from the following files: