-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
//2022.6.25 P.M.1:44 | ||
//TPAXcc Form github.com/TPAXcc/Arduino-Ultrasonic | ||
//添加注释 | ||
|
||
#ifndef HC-SR04_h | ||
#define HC-SR04_h //定义 HC-SR04.h 头文件 | ||
|
||
//Arduino 版本兼容 | ||
#if ARDUINO >= 100 | ||
#include "Arduino.h" | ||
#else | ||
#include "WProgram.h" | ||
#endif | ||
|
||
class SR04 { //声明 SR04 类 | ||
public: | ||
SR04(int TP, int EP); //声明 SR04 函数用于初始化对象 | ||
float Get(); //声明 Get 函数用于数据获取/处理 | ||
|
||
private: | ||
//记录所用引脚 | ||
int Trig_Pin; | ||
int Echo_Pin; | ||
//记录回传数据 | ||
float distance; | ||
|
||
}; | ||
|
||
#endif |