質問編集履歴
1
やってみたことの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -45,3 +45,161 @@
|
|
45
45
|
|
46
46
|
|
47
47
|

|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
<2019/12/12/17:31_追記>
|
52
|
+
|
53
|
+
どこでエラーが発生しているか確認するためにあちこちにprint文を入れました。
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
```python3
|
58
|
+
|
59
|
+
from gpiozero import MCP3208
|
60
|
+
|
61
|
+
import RPi.GPIO as GPIO
|
62
|
+
|
63
|
+
import time
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
GPIO.setmode(GPIO.BCM)
|
68
|
+
|
69
|
+
GPIO.setup(21,GPIO.OUT)
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
while True:
|
74
|
+
|
75
|
+
time.sleep(1)
|
76
|
+
|
77
|
+
print(MCP3208(channel = 0).value)
|
78
|
+
|
79
|
+
if MCP3208(channel = 0).value > 0.01:
|
80
|
+
|
81
|
+
GPIO.output(21,GPIO.HIGH)
|
82
|
+
|
83
|
+
print('low')
|
84
|
+
|
85
|
+
else:
|
86
|
+
|
87
|
+
print('error')
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
GPIO.cleanup()
|
92
|
+
|
93
|
+
print('not_true')
|
94
|
+
|
95
|
+
```
|
96
|
+
|
97
|
+
shellには以下のように少しだけ動いてからエラーがでました
|
98
|
+
|
99
|
+
```python3
|
100
|
+
|
101
|
+
0.0006104260774020265
|
102
|
+
|
103
|
+
low
|
104
|
+
|
105
|
+
0.0006104260774020265
|
106
|
+
|
107
|
+
low
|
108
|
+
|
109
|
+
0.0006104260774020265
|
110
|
+
|
111
|
+
low
|
112
|
+
|
113
|
+
0.0006104260774020265
|
114
|
+
|
115
|
+
low
|
116
|
+
|
117
|
+
0.0023196190941277006
|
118
|
+
|
119
|
+
low
|
120
|
+
|
121
|
+
0.004517152972774996
|
122
|
+
|
123
|
+
low
|
124
|
+
|
125
|
+
0.0006104260774020265
|
126
|
+
|
127
|
+
low
|
128
|
+
|
129
|
+
0.0059821755585398595
|
130
|
+
|
131
|
+
low
|
132
|
+
|
133
|
+
0.015993163227933094
|
134
|
+
|
135
|
+
high
|
136
|
+
|
137
|
+
0.015016481504089851
|
138
|
+
|
139
|
+
high
|
140
|
+
|
141
|
+
0.0006104260774020265
|
142
|
+
|
143
|
+
low
|
144
|
+
|
145
|
+
0.0006104260774020265
|
146
|
+
|
147
|
+
low
|
148
|
+
|
149
|
+
0.0006104260774020265
|
150
|
+
|
151
|
+
low
|
152
|
+
|
153
|
+
0.0006104260774020265
|
154
|
+
|
155
|
+
low
|
156
|
+
|
157
|
+
0.0006104260774020265
|
158
|
+
|
159
|
+
low
|
160
|
+
|
161
|
+
0.0006104260774020265
|
162
|
+
|
163
|
+
```
|
164
|
+
|
165
|
+
ここでフリーズしてしまったのでctrl+cを打つと、
|
166
|
+
|
167
|
+
```python3
|
168
|
+
|
169
|
+
Exception ignored in: <bound method SharedMixin.__del__ of SPI(closed)>
|
170
|
+
|
171
|
+
Traceback (most recent call last):
|
172
|
+
|
173
|
+
File "/usr/lib/python3/dist-packages/gpiozero/mixins.py", line 137, in __del__
|
174
|
+
|
175
|
+
super(SharedMixin, self).__del__()
|
176
|
+
|
177
|
+
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 122, in __del__
|
178
|
+
|
179
|
+
self.close()
|
180
|
+
|
181
|
+
File "/usr/lib/python3/dist-packages/gpiozero/devices.py", line 82, in close
|
182
|
+
|
183
|
+
old_close()
|
184
|
+
|
185
|
+
File "/usr/lib/python3/dist-packages/gpiozero/pins/local.py", line 102, in close
|
186
|
+
|
187
|
+
self.pin_factory.release_all(self)
|
188
|
+
|
189
|
+
File "/usr/lib/python3/dist-packages/gpiozero/pins/__init__.py", line 85, in release_all
|
190
|
+
|
191
|
+
with self._res_lock:
|
192
|
+
|
193
|
+
File "/usr/lib/python3/dist-packages/thonny/shared/thonny/backend.py", line 133, in signal_handler
|
194
|
+
|
195
|
+
raise KeyboardInterrupt("Execution interrupted")
|
196
|
+
|
197
|
+
KeyboardInterrupt: Execution interrupted
|
198
|
+
|
199
|
+
KeyboardInterrupt: Forced reset
|
200
|
+
|
201
|
+
>>>
|
202
|
+
|
203
|
+
```
|
204
|
+
|
205
|
+
と表示されました。
|