
--- README.md
+++ README.md
... | ... | @@ -2,5 +2,78 @@ |
2 | 2 |
|
3 | 3 |
## 아두이노 테스트 코드 |
4 | 4 |
|
5 |
-- |
|
5 |
+### 모터 구동 테스트 코드 |
|
6 |
+''' |
|
7 |
+const int PWM = 10; // MD200T 6번 (SPEED_IN2) 노랑 |
|
8 |
+const int DIR = 8; // MD200T 2번 (DIR2) 주황 |
|
9 |
+const int ST = 9; // MD200T 4번 (START/STOP2) 초록 |
|
10 |
+ |
|
11 |
+void setup() { |
|
12 |
+ Serial.begin(9600); |
|
13 |
+ |
|
14 |
+ pinMode(PWM, OUTPUT); |
|
15 |
+ pinMode(DIR, OUTPUT); // 회전 방향 (시계 방향 = HIGH) |
|
16 |
+ pinMode(ST, OUTPUT); // 브레이크 (해제 = LOW) |
|
17 |
+ |
|
18 |
+ digitalWrite(ST, HIGH); |
|
19 |
+ delay(2000); // 전원 안정화 |
|
20 |
+} |
|
21 |
+ |
|
22 |
+void loop() { |
|
23 |
+ |
|
24 |
+ digitalWrite(ST, LOW); // 브레이크 해제 |
|
25 |
+ digitalWrite(DIR, LOW); // 반시계 회전 |
|
26 |
+ analogWrite(PWM, 0); |
|
27 |
+ // delay(10000); |
|
28 |
+ // digitalWrite(ST, HIGH); // 멈춤 |
|
29 |
+ // delay(4000); |
|
30 |
+ |
|
31 |
+ // digitalWrite(ST, LOW); |
|
32 |
+ // digitalWrite(DIR, HIGH); // 시계 회전 |
|
33 |
+ // analogWrite(PWM, 125); |
|
34 |
+ // delay(10000); |
|
35 |
+ // digitalWrite(ST, HIGH); |
|
36 |
+ // delay(4000); |
|
37 |
+} |
|
38 |
+''' |
|
39 |
+ |
|
40 |
+## 홀센서 확인 테스트 코드 |
|
41 |
+ |
|
42 |
+''' |
|
43 |
+// 홀센서 핀 번호 |
|
44 |
+const int Hu = 4; |
|
45 |
+const int Hv = 3; |
|
46 |
+const int Hw = 2; |
|
47 |
+ |
|
48 |
+const int PWM = 10; // MD200T 6번 (SPEED_IN2) 노랑 |
|
49 |
+const int DIR = 8; // MD200T 2번 (DIR2) 주황 |
|
50 |
+const int ST = 9; // MD200T 4번 (START/STOP2) 초록 |
|
51 |
+ |
|
52 |
+void setup() { |
|
53 |
+ Serial.begin(9600); |
|
54 |
+ |
|
55 |
+ pinMode(Hu, INPUT); |
|
56 |
+ pinMode(Hv, INPUT); |
|
57 |
+ pinMode(Hw, INPUT); |
|
58 |
+ |
|
59 |
+ pinMode(PWM, OUTPUT); |
|
60 |
+ pinMode(DIR, OUTPUT); // 회전 방향 (시계 방향 = HIGH) |
|
61 |
+ pinMode(ST, OUTPUT); |
|
62 |
+ digitalWrite(ST, HIGH); // 브레이크 (해제 = LOW) |
|
63 |
+ delay(2000); // 전원 안정화 |
|
64 |
+} |
|
65 |
+ |
|
66 |
+//모터를 직접 손으로 돌리면서 체크 |
|
67 |
+void loop() { |
|
68 |
+ int hu = digitalRead(Hu); |
|
69 |
+ int hv = digitalRead(Hv); |
|
70 |
+ int hw = digitalRead(Hw); |
|
71 |
+ |
|
72 |
+ Serial.print("Hu: "); Serial.print(hu); |
|
73 |
+ Serial.print(" | Hv: "); Serial.print(hv); |
|
74 |
+ Serial.print(" | Hw: "); Serial.println(hw); |
|
75 |
+ |
|
76 |
+ delay(200); // 0.2초 간격 출력 |
|
77 |
+} |
|
78 |
+''' |
|
6 | 79 |
|
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?