ME507 Airheads Project v1.1.0
Flight Stabilization for Glider
Loading...
Searching...
No Matches
ultrasonic.h
Go to the documentation of this file.
1
9// Compile the header file only once
10#ifndef ULTRASONIC
11#define ULTRASONIC
12
13#include <Arduino.h>
14
17class Ultrasonic //This class operates an HC_SR04 Ultrasonic Sensor
18{
19protected:
20 float distance;
21 uint8_t echoPin;
22 uint8_t trigPin;
23 long duration;
24
25
26public:
27 Ultrasonic (uint8_t echoPin, uint8_t trigPin);
28 float get_distance (void);
29};
30
31#endif // ULTRASONIC
Class for an HC_SR04 Ultrasonic Sensor.
Definition: ultrasonic.h:18
uint8_t trigPin
The GPIO trigger pin that sends out ultrasonic pulses.
Definition: ultrasonic.h:22
float distance
The distance between the ultrasonic sensor and the object in front of it.
Definition: ultrasonic.h:20
uint8_t echoPin
The GPIO echo pin used to measure the time between ultrasonic pulses.
Definition: ultrasonic.h:21
float get_distance(void)
The method to get the distance measured from the ultrasonic sensor.
Definition: ultrasonic.cpp:36
long duration
The time between received ultrasonic pulses.
Definition: ultrasonic.h:23