質問編集履歴
1
プログラムの書式変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -30,9 +30,9 @@
|
|
30
30
|
|
31
31
|
```python3
|
32
32
|
|
33
|
-
|
33
|
+
/usr/bin/env python
|
34
34
|
|
35
|
-
|
35
|
+
# -*- coding: utf-8 -*-
|
36
36
|
|
37
37
|
import Adafruit_PCA9685
|
38
38
|
|
@@ -40,13 +40,13 @@
|
|
40
40
|
|
41
41
|
|
42
42
|
|
43
|
-
|
43
|
+
#емМТмпмВггЈЭмЫЙЋПЁЮЯЩй
|
44
44
|
|
45
45
|
class servo_Class:
|
46
46
|
|
47
|
-
|
47
|
+
#ChannelЯPCA9685ЮемМТмпмВދЄРЁУгЍЫ
|
48
48
|
|
49
|
-
|
49
|
+
#ZeroOffsetЯемМТмпмЮΖЮύ߮ВʿۀЙЋПЁЮБЩСмпмЧЙ
|
50
50
|
|
51
51
|
def __init__(self, Channel, ZeroOffset):
|
52
52
|
|
@@ -56,7 +56,7 @@
|
|
56
56
|
|
57
57
|
|
58
58
|
|
59
|
-
|
59
|
+
#Adafruit_PCA9685ЮҝǟӖ
|
60
60
|
|
61
61
|
self.pwm = Adafruit_PCA9685.PCA9685(address=0x40)
|
62
62
|
|
@@ -64,23 +64,23 @@
|
|
64
64
|
|
65
65
|
|
66
66
|
|
67
|
-
"""
|
67
|
+
"""ɒަВʭۚЙЋբŰЧЙ"""
|
68
68
|
|
69
69
|
def SetPos(self,pos):
|
70
70
|
|
71
71
|
|
72
72
|
|
73
|
-
|
73
|
+
#pulse = 1500 : 0 ߞ 180ަ
|
74
74
|
|
75
|
-
|
75
|
+
#PCA9685ЯБЫйЧɒަВҶߡЗЦЄЋПЁ0~180ЮЈІЫɒަВÇۚЗЦЂУПɒަЫЯЪЊоЛГ
|
76
76
|
|
77
|
-
|
77
|
+
#НГЧɒަЮФЋЉБЫйЮФиШىÛЗоЙЂPCA9685ЧЯБЫ๕0~650ЌɒަЮ0~180Ы۾ߜЗЦЄЋпПЄЧЙ
|
78
78
|
|
79
|
-
|
79
|
+
#ЮߏЮ(650-150)/180Я1ަЂПЊЮБЫйВȨЗЦЄоЙ
|
80
80
|
|
81
|
-
|
81
|
+
#НЌЫpos(ҶߡЗПЄɒަ)ВÛБПߌU0ВͳЙГШЧГШЧɒަВБЫйЫִЗЦЄоЙЂ
|
82
82
|
|
83
|
-
|
83
|
+
#ǀߌЫZeroOffsetВͳЙГШЧΖЫЗПЄύ߮ЫȜˣЗоЙ
|
84
84
|
|
85
85
|
pulse = int(2.7)*pos+150+self.ZeroOffset
|
86
86
|
|
@@ -90,23 +90,23 @@
|
|
90
90
|
|
91
91
|
|
92
92
|
|
93
|
-
"""
|
93
|
+
"""ҶߡВȌІСФгЮШ҆ЧЙ"""
|
94
94
|
|
95
95
|
if __name__ == '__main__':
|
96
96
|
|
97
|
-
|
97
|
+
#Ί֞ЯемМТмпмЌ3ФЂЊоЙ
|
98
98
|
|
99
99
|
Servo0 = servo_Class(Channel=0, ZeroOffset=-5)
|
100
100
|
|
101
|
-
Servo1 = servo_Class(Channel=1, ZeroOffset=-5)
|
101
|
+
#Servo1 = servo_Class(Channel=1, ZeroOffset=-5)
|
102
102
|
|
103
|
-
Servo2 = servo_Class(Channel=2, ZeroOffset=-5)
|
103
|
+
#Servo2 = servo_Class(Channel=2, ZeroOffset=-5)
|
104
104
|
|
105
105
|
|
106
106
|
|
107
107
|
try:
|
108
108
|
|
109
|
-
|
109
|
+
#ІйЈЧНЌОЌЮемМТмпм҅ަ,90ަШްЊϔЗҕЋЗЦпоЙЂ
|
110
110
|
|
111
111
|
while True:
|
112
112
|
|
@@ -116,13 +116,13 @@
|
|
116
116
|
|
117
117
|
time.sleep(1)
|
118
118
|
|
119
|
-
Servo1.SetPos(45)
|
119
|
+
#Servo1.SetPos(45)
|
120
120
|
|
121
|
-
time.sleep(2)
|
121
|
+
#time.sleep(2)
|
122
122
|
|
123
|
-
Servo2.SetPos(45)
|
123
|
+
#Servo2.SetPos(45)
|
124
124
|
|
125
|
-
time.sleep(2)
|
125
|
+
#time.sleep(2)
|
126
126
|
|
127
127
|
|
128
128
|
|
@@ -132,23 +132,25 @@
|
|
132
132
|
|
133
133
|
time.sleep(1)
|
134
134
|
|
135
|
-
Servo1.SetPos(90)
|
135
|
+
#Servo1.SetPos(90)
|
136
136
|
|
137
|
-
time.sleep(2)
|
137
|
+
#time.sleep(2)
|
138
138
|
|
139
|
-
Servo2.SetPos(90)
|
139
|
+
#Servo2.SetPos(90)
|
140
140
|
|
141
|
-
time.sleep(2)
|
141
|
+
#time.sleep(2)
|
142
142
|
|
143
143
|
|
144
144
|
|
145
|
-
except KeyboardInterrupt : #Ctl+C
|
145
|
+
except KeyboardInterrupt : #Ctl+Cをおしたら終了
|
146
146
|
|
147
147
|
print("\nCtl+C")
|
148
148
|
|
149
149
|
except Exception as e:
|
150
150
|
|
151
151
|
print(str(e))
|
152
|
+
|
153
|
+
```
|
152
154
|
|
153
155
|
### 試したこと
|
154
156
|
|