![]() |
MOREbot Library
v1.1.1
|
Ultrasonic class. More...
#include <MOREbot.h>
Public Member Functions | |
ultrasonic (int trig, int echo) | |
Ultrasonic constructor. More... | |
float | readDistance () |
Function to get distance from the Ultrasonic. More... | |
Ultrasonic class.
Handles communicating with the ultrasonic module to determine distance to the nearest object.
ultrasonic::ultrasonic | ( | int | trig, |
int | echo | ||
) |
Ultrasonic constructor.
Saves the pins to communicate with the ultrasonic module.
trig | an integer. The pin on the arduino that the ultrasonic's trig pin is connected to. |
echo | an integer. The pin on the arduino that the ultrasonic's echo pin is connected to. |
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.