File tree 1 file changed +55
-3
lines changed
1 file changed +55
-3
lines changed Original file line number Diff line number Diff line change 2
2
3
3
거리센서
4
4
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
+
5
17
### ✔ 연결방법
6
18
19
+ ![ image] ( https://user-images.githubusercontent.com/54584063/84300956-f5c09980-ab8d-11ea-8796-be2c8df96501.png )
20
+
7
21
8
22
<br ><br >
9
23
10
- ### ✔
24
+ ### ✔ LAB
25
+
26
+ - 초음파 센서 값 출력
27
+
28
+ ``` js
29
+ int trigPin = 3 ;
30
+ int echoPin = 2 ;
11
31
32
+ void setup () {
33
+ Serial .begin (9600 );
34
+ pinMode (trigPin, OUTPUT );
35
+ pinMode (echoPin, INPUT );
36
+ }
12
37
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
+ ```
13
52
< br>< br>
14
53
15
- ### ✔ LAB
54
+ ### 🔎 pulseIn ()
55
+
56
+ pulseIn (pin, value)
57
+
58
+ pulseIn (pin, value, timeout)
16
59
60
+ value (LOW / HIGH ) 로 있는 동안의 시간을 return
61
+
62
+ ! [image](https: // user-images.githubusercontent.com/54584063/84301811-5dc3af80-ab8f-11ea-9e0c-c58ab6c83c95.png)
17
63
18
64
19
65
< br>< br>
20
66
21
- ### 🔎 정리
67
+ ### 🔎 정리
68
+
69
+ - Ultrasonic 초음파 센서
70
+
71
+ - 초음파 펄스를 출력, 수신
72
+
73
+ - 시간 측정 - > 거리 계산
You can’t perform that action at this time.
0 commit comments