You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
766 B
31 lines
766 B
#ifndef __PULSE_H_
|
|
#define __PLUSE_H_
|
|
|
|
class Pulse {
|
|
private:
|
|
int trigPin;
|
|
int echoPin;
|
|
public:
|
|
|
|
Pulse(int t,int e) : trigPin(t),echoPin(e) {
|
|
pinMode(t,OUTPUT);
|
|
pinMode(e,INPUT);
|
|
}
|
|
void Trig() { // trigPin에 LOW를 출력하고
|
|
digitalWrite(trigPin, LOW); // trigPin에 LOW를 출력하고
|
|
|
|
delayMicroseconds(2); // 2 마이크로초가 지나면
|
|
|
|
digitalWrite(trigPin, HIGH); // trigPin에 HIGH를 출력합니다.
|
|
|
|
delayMicroseconds(10); // trigPin을 10마이크로초 동안 기다렸다가
|
|
|
|
digitalWrite(trigPin, LOW);
|
|
}
|
|
|
|
unsigned long Echo() {
|
|
return pulseIn(echoPin,HIGH);
|
|
}
|
|
|
|
};
|
|
#endif
|