Skip to content

Commit 9269c1a

Browse files
committed
docs : 초음파센서
1 parent c1f7917 commit 9269c1a

File tree

1 file changed

+55
-3
lines changed

1 file changed

+55
-3
lines changed

부품&연결방법/초음파센서.md

+55-3
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,72 @@
22

33
거리센서
44

5+
![image](https://user-images.githubusercontent.com/54584063/84301325-8e571980-ab8e-11ea-9d9d-9c5e5cd6b656.png)
6+
7+
![image](https://user-images.githubusercontent.com/54584063/84301404-ad55ab80-ab8e-11ea-99df-2c44694576f6.png)
8+
9+
- Vcc : 전압
10+
11+
- Trigger : Input pin
12+
13+
- Echo : Output pin
14+
15+
- Grount
16+
517
### ✔ 연결방법
618

19+
![image](https://user-images.githubusercontent.com/54584063/84300956-f5c09980-ab8d-11ea-8796-be2c8df96501.png)
20+
721

822
<br><br>
923

10-
###
24+
### ✔ LAB
25+
26+
- 초음파 센서 값 출력
27+
28+
```js
29+
int trigPin = 3;
30+
int echoPin = 2;
1131

32+
void setup() {
33+
Serial.begin(9600);
34+
pinMode(trigPin, OUTPUT);
35+
pinMode(echoPin, INPUT);
36+
}
1237

38+
void loop() {
39+
digitalWrite(trigPin, HIGH);
40+
delay(10);
41+
digitalWrite(trigPin, LOW);
42+
43+
// Reads the echoPin, returns the sound wave travel time in microseconds
44+
float duration = pulseIn(echoPin, HIGH);
45+
46+
float distance = duration * 340 / 10000 / 2;
47+
Serial.println(String("Distance(cm): ") + distance);
48+
delay(500);
49+
}
50+
51+
```
1352
<br><br>
1453

15-
### ✔ LAB
54+
### 🔎 pulseIn()
55+
56+
pulseIn(pin, value)
57+
58+
pulseIn(pin, value, timeout)
1659

60+
value(LOW/HIGH) 로 있는 동안의 시간을 return
61+
62+
![image](https://user-images.githubusercontent.com/54584063/84301811-5dc3af80-ab8f-11ea-9e0c-c58ab6c83c95.png)
1763

1864

1965
<br><br>
2066

21-
### 🔎 정리
67+
### 🔎 정리
68+
69+
- Ultrasonic 초음파 센서
70+
71+
- 초음파 펄스를 출력, 수신
72+
73+
- 시간 측정 -> 거리 계산

0 commit comments

Comments
 (0)