기업연계 프로젝트2 15조 팀명: 소도기
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.

30 lines
766 B

5 years ago
  1. #ifndef __PULSE_H_
  2. #define __PLUSE_H_
  3. class Pulse {
  4. private:
  5. int trigPin;
  6. int echoPin;
  7. public:
  8. Pulse(int t,int e) : trigPin(t),echoPin(e) {
  9. pinMode(t,OUTPUT);
  10. pinMode(e,INPUT);
  11. }
  12. void Trig() { // trigPin에 LOW를 출력하고
  13. digitalWrite(trigPin, LOW); // trigPin에 LOW를 출력하고
  14. delayMicroseconds(2); // 2 마이크로초가 지나면
  15. digitalWrite(trigPin, HIGH); // trigPin에 HIGH를 출력합니다.
  16. delayMicroseconds(10); // trigPin을 10마이크로초 동안 기다렸다가
  17. digitalWrite(trigPin, LOW);
  18. }
  19. unsigned long Echo() {
  20. return pulseIn(echoPin,HIGH);
  21. }
  22. };
  23. #endif