ME507 Airheads Project v1.1.0
Flight Stabilization for Glider
Loading...
Searching...
No Matches
Ultrasonic Class Reference

Class for an HC_SR04 Ultrasonic Sensor. More...

#include <ultrasonic.h>

Public Member Functions

 Ultrasonic (uint8_t echoPin, uint8_t trigPin)
 Constructor for the ultrasonic sensor class. More...
 
float get_distance (void)
 The method to get the distance measured from the ultrasonic sensor. More...
 

Protected Attributes

float distance
 The distance between the ultrasonic sensor and the object in front of it.
 
uint8_t echoPin
 The GPIO echo pin used to measure the time between ultrasonic pulses.
 
uint8_t trigPin
 The GPIO trigger pin that sends out ultrasonic pulses.
 
long duration
 The time between received ultrasonic pulses.
 

Detailed Description

Class for an HC_SR04 Ultrasonic Sensor.

Constructor & Destructor Documentation

◆ Ultrasonic()

Ultrasonic::Ultrasonic ( uint8_t  echo,
uint8_t  trig 
)

Constructor for the ultrasonic sensor class.

Constructor which creates an ultrasonic sensor object.

Parameters
echoThe GPIO pin used to measure the time between ultrasonic pulses
trigThe GPIO pin used to send out ultrasonic pulses

Member Function Documentation

◆ get_distance()

float Ultrasonic::get_distance ( void  )

The method to get the distance measured from the ultrasonic sensor.

Measure the distance between the sensor and the object in front of it.

Returns
The distance, in centimeters, between the sensor and the object in front of it

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